I was reading some 3rd party code and I found this:
x.Flags = x.Flags ^ Flags.Hidden;
What does it do?
I've used '&' and '|' for bitwise 'and' and 'or' with enums, but it's the first time I see the that symbol...
The ' |= ' symbol is the bitwise OR assignment operator.
-= Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. C -= A is equivalent to C = C - A.
The && (logical AND) operator indicates whether both operands are true. If both operands have nonzero values, the result has the value 1 . Otherwise, the result has the value 0 . The type of the result is int . Both operands must have an arithmetic or pointer type.
^ is the bitwise XOR operator in C#.
EDIT: a ^ b returns true if a is true and b is false or if a is false and b is true, but not both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With