I have this piece of code in MyClass:
public static bool operator ==(MyClass lhs, MyClass rhs) { if (lhs == null || rhs == null) return false; // Other operations to check for equality } Going by the first line in the code, I'm comparing lhs and rhs to null. I'm not sure but I suppose that comparison itself will invoke the overload function again. And then we het to that line again, it invokes itself and so on. Sort of an infinite recursion.
But we all know that does not take place. This implies, in my opinion, that comparing with null does not invoke the equality overload. So what really occurs? How does comparing with null work?
lhsandrhsarenull?lhs == nullnot both are objects ofMyClassnull? That's something. Can it ever be useful, though?