What does this operator ^= mean in c#?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means bitwise XOR the value of the LHS expression with the value of the RHS expression, and assign it back to the LHS expression.
So for example:
The LHS expression is only evaluated once, so if you have:
that would only call
GetIndexonce. But please don’t do that, ‘cos it’s nasty 🙂See also the relevant MSDN page.
You may also find Eric Lippert’s recent April Fool’s Day blog post on compound assignment operators amusing – and part one of the series, which was rather more serious, may prove enlightening.