Assignment Operator C # ^ =

What does this ^ = operator mean in C #?

+5
source share
5 answers

This means the bitwise XOR value of the LHS expression with the value of the RHS expression and assigns it back to the LHS expression.

So for example:

int x = 10;
int y = 3;

x ^= y; // x = 10 ^ 3, i.e. 9

An LHS expression is evaluated only once, so if you have:

array[GetIndex()] ^= 10;

which will only call once GetIndex. But please do not do this because it is disgusting :)

See also the corresponding MSDN page .

, , - , , .

+5

x ^= y;

:

x = x ^ y;

x x exclusive y.

+2

.

 x ^= y

 x = x ^ y

, x . ^ -OR bool.

http://msdn.microsoft.com/en-us/library/0zbsw2z6.aspx

+1

XOR. a ^= b a = a ^ b, a b - .

+1

All Articles