In this question. we discovered that in .NET 1.1, Array.IndexOf(array, value)
searched for an element with
value.Equals(arrayElement) == true
while .NET 2.0 changed it to search for an element with
arrayElement.Equals(value) == true
Obviously the potential difference between the two results arises from polymorphism, but is there any reason why the latter version is preferable? More generally, if I have two objects a
and b
to compare, is there any good reason to prefer a.Equals(b)
or b.Equals(a)
?