Thursday, January 26, 2006

XOR operator in C#

There is a XOR operator in C#!!!
For some reason, it’s impossible to find it by searching for “XOR” in MSDN (either in the index or using the search). I don’t know why they’re trying to hide that…
So anyway, it’s a simple bitwise operator: ^
So:

C = A XOR B should be written: C = A^B;

(and there’s of course the complementary ^= which also performs an assignment)

1 comment:

Tomer Gabel said...

C# derives more or less directly from C (at least as far as basic syntax is concerned), so I'd imagine they simply neglected to document it :-) Send them an e-mail, might help.