Reputation: 31313
I have an easy question that I think I know the answer but I will ask here.
Is the code...
var test = true;
test = test && true; // test remains true
test = test && false; // test is now false
Equivalent to the code...
var test = true;
test &= true;
test &= false;
&= is a bitwise operation, so I am surprised the compiler will even allow this?
Upvotes: 2
Views: 86
Reputation: 667
It works, but not the same way as in first code. The equivalent code:
var test = true;
test = test & true;
test = test & false;
C# doesn't have &&= operator
Upvotes: 2