How come C# doesn’t have a conditional XOR operator?
Example:
true xor false = true
true xor true = false
false xor false = false
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.
In C#, conditional operators only execute their secondary operand if necessary.
Since an XOR must by definition test both values, a conditional version would be silly.
Examples:
Logical AND:
&– tests both sides every time.Logical OR:
|– test both sides every time.Conditional AND:
&&– only tests the 2nd side if the 1st side is true.Conditional OR:
||– only test the 2nd side if the 1st side is false.