[Mono-list] Reflection bug

Jeroen Frijters jeroen@sumatra.nl
Fri, 1 Nov 2002 14:28:18 +0100


Hi,

The following code runs incorrectly:
  object o = "foo";
  Console.WriteLine(o.GetHashCode());
  Console.WriteLine(typeof(object).GetMethod("GetHashCode").Invoke(o,
null));
  Console.WriteLine(typeof(string).GetMethod("GetHashCode").Invoke(o,
null));

The second line invokes GetHashCode in System.Object, instead of in
System.String. This is incorrect. Please note that Microsoft's
implementation of .NET version 1.0 has the same bug (but only for
System.String), it is however, not the correct behavior. MS has fixed it
in the current 1.1 beta.

Regards,
Jeroen