问题
I read that the ^
operator is the logical XOR operator in C#, but I also thought it was the "power of" operator. What is the explanation?
回答1:
It is not the power of operator of C# since there is no such operator in C#. It is just the XOR operator.
For "power of", use Math.Pow.
As you can see from this page on the C# Operators, ^
is listed under the "Logical (boolean and bitwise)" category, which means it can both handle boolean values, and binary values (for bitwise XOR).
来源:https://stackoverflow.com/questions/1508153/is-the-operator-really-the-xor-operator-in-c