Conditional XOR?

Gilad Naaman picture Gilad Naaman · Jun 28, 2011 · Viewed 78.2k times · Source

How come C# doesn't have a conditional XOR operator?

Example:

true  xor false = true
true  xor true  = false
false xor false = false

Answer

piotrpo picture piotrpo · Feb 2, 2013

Question is a bit outdated but...

It's how this operator should work:

true xor false = true
true xor true = false
false xor true = true
false xor false = false

This is how != operator works with bool types:

(true != false) // true
(true != true) // false
(false != true) // true
(false != false) // false

So as you see unexisting ^^ can be replaced with existing !=