You can use RuntimeHelpers.GetHashCode(object)
to get the original hash code of the object:
class A
{
public override int GetHashCode()
{
Console.WriteLine("base hashcode is: " + base.GetHashCode());
return 1;
}
}
class Program
{
public static void Main(string[] args)
{
A a = new A();
Console.WriteLine("A's hashcode: " + a.GetHashCode());
Console.WriteLine("A's original hashcode: " + RuntimeHelpers.GetHashCode(a));
}
}
This produces the following result:
base hashcode is: 54267293
A's hashcode: 1
A's original hashcode: 54267293
If you take a look at RuntimeHelpers.GetHashCode(object)
in Reflector, you'll see that it calls the internal static method object.InternalGetHashCode(object)
. If you'd like to know more, have a look at this question regarding the default implementation of GetHashCode.