On 9/28/06, Ron Grabowski <[EMAIL PROTECTED]> wrote:
public static int GetIdentityHashCode(object obj)
{
System.Reflection.MethodInfo methodInfo = null;
Type type = typeof(object);
methodInfo = type.GetMethod("GetHashCode");
return (int) methodInfo.Invoke(obj, null);
}
Why can't we call:
public static int GetIdentityHashCode(object obj)
{
return obj.GetHashCode();
}
Does using reflection call the framework's GetHashCode method even if the
object has overriden it?
Yes bug in .NET 1.0
Can we cache the MethodInfo?
Yes, with a cache with object type as key
--
Cheers,
Gilles
<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>