joeycalisay:They all raise NullReferenceException whether it does not involve null or null is at the left or at the right of the operator.
Anyway, although i've seen suggestions to not override equality operators and use Equals override instead, they are there for convenience and for readability (imo). There's just something wrong with my code which is the basics for overriding Equals and equality operators, anyone?
Yeah upon closer inspection it does seem that a NullReferenceException will occur first before the StackOverFlow exception. This is because after some back and forth between == and Equals(), a null value will eventually be assigned to the left operand.
Take the case of your first test case:
MyClass myClass1 = new MyClass(1);
MyClass myClass2 = new MyClass(2);
bool equal = myClass1 == myClass2;
1) call to ==: left = myClass1, right = myClass2
2) call to Equals(): obj = myclass2
3) call to ==: left = myClass2 , right = null
4) call to Equals(): obj = null
5) call to ==: left = null, right = null ----> exception!