
Some methods in .NET are like landmines: they lie in plain sight, they look harmless, and the compiler lets you step right on them.
Two of them are object.ReferenceEquals(object, object) and object.Equals(object). Both accept arguments of type object, which means that they accept any arguments at all, even arguments for which the answer can only ever be false. The compiler does not issue an error about such invocations, not even a warning, which is something that I, personally, find preposterous.
This post shows how you can get the compiler, or at least Visual Studio, to point out such mistakes.
Read more »