ReferenceEquals does exactly what you need if you are not talking about a dictionary. It does not check Equals (it is literally just ldarg.0 , ldarg.1 , ceq , ret ). Alternatively, just reset the object:
bool same = (object)x == (object)y;
If you need dictionary support (like this: GetHashCode ): System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj) is your friend.
Marc gravell
source share