Compiler error CS0019: comparing two integers
In C #, why is the first if statement giving me a compilation error but not the second? Can someone please explain?
1) if(num & 1 == 1) { Console.WriteLine("Test"); }
This gives me: Error CS0019 Operator '&' cannot be applied to operands of type 'int' and 'bool'.
2)
var x = num & 1;
if (x == 1) { Console.WriteLine("Test"); }
This compiles fine.
+3
source to share