In this MSDN article, it says that
In the .NET Framework version 2.0, this method uses the Equals and CompareTo methods of the Array to determine whether the Object specified by the value parameter exists. In the earlier versions of the .NET Framework, this determination was made by using the Equals and CompareTo methods of the value Object itself.
What exactly does this mean? From what I can tell using Reflector, Array.IndexOf still uses the equals method of the object to determine the index of the object in the array:
for (int j = startIndex; j < num3; j++)
{
object obj2 = objArray[j];
if ((obj2 != null) && obj2.Equals(value))
{
return j;
}
}
This is what I expected, but I’m a little confused by the MSDN Remark.
It’s (very) poorly worded, but it means that in 1.1, it searched for an
arrayElementwithwhile in 2.0 it searches for one with
That is, the equivalent piece of reflected code from 1.1 was