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 \'|
^ 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.
That would be the 'xor' operator. In your example code, it would toggle the Flags.Hidden either on or off, depending on the current value of x.Flags.
The benefit of doing it this way is that it allows you to change the setting for Flags.Hidden without affecting any other flags that have been set.
Taken from here:
For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if an odd number of its operands is true.
It's the exclusive OR (XOR) operator, this link has example usage
http://weblogs.asp.net/alessandro/archive/2007/10/02/bitwise-operators-in-c-or-xor-and-amp-amp-not.aspx