Monday, February 23rd, 2009
Overloading == in C#
When overriding the == operator on immutable objects, I’ve previously done something akin to public static bool operator ==(MyThing x, MyThing y){ // Null tests try {var ignore = x.GetType(); } // Provoke NRE catch(NullReferenceException) { try { var ignore = y.GetType(); return false; // Only one operand null } catch (NullReferenceException) { // Both [...]
