1U
is not ulong
. It's uint
. Declare test
and t
as ulong
and you'll get what you need:
var test = 1UL;
var t1 = ~test;
var t = 1UL;
for (int i = 0; i < 64; i++)
{
Console.Write((t & t1) != 0 ? 1 : 0);
t <<= 1;
}
prints
01111111111111111111111111111111111111111111111111111111111111