Curtis Rutland, on 27 February 2012 - 02:39 PM, said:
baavgai, on 27 February 2012 - 11:54 AM, said:
So & and && are identical for boolean (in C#)!
Actually, that's not correct either, proven by the link you provided.
For integral types, & computes the logical bitwise AND of its operands. For bool operands, & computes the logical AND of its operands; that is, the result is true if and only if both its operands are true.
Please explain how my statement is incorrect, when it's what Microsoft explicitly states.
This post has been edited by baavgai: 28 February 2012 - 05:24 AM
C# has overloaded the & operator to behave like a && with bool types. So & and && are identical for boolean (in C#)!
Is incorrect, because it's not identical behavior. One uses short circuit logic, and the other doesn't. That's the point I was trying to get across. The result is the same, but the side effects can be different, which could be completely unimportant, or critically important, depending on the way you write the code.