.NET Framework changes affecting Items 9, 10
The advice is still proper, but the justification is somewhat different.The 2.0 version of the .NET framework has changed the way they implement ValueType.Equals() and ValueType.GetHashCode(). This affects some of the justification for my advice in items 9 and 10.
I explained in Item 9 that these methods use Reflection to determine if the values stored are equal. Further, that as a performance improvement, only the first field in the value type was compared, instead of each field. A similar algorithm was used in ValueType.GetHashCode(): This method returned the hash code of the first field in the value type.
This behavior changes in 2.0. Beta 1 and Beta 2 now use all the fields in a value type to determine equality, and to calculate the hash code.
These changes do not fundamentally affect the advice I set forth in Items 9 and 10. (In fact, if you are already following my advice, the changes to the implementation of these methods will be transparent to you.) You should still override both methods, Equals and GetHashCode) for ValueTypes. While the implementations in the 2.0 framework are more correct than their predecessors, they will have a negative impact on performance because of their use of reflection. Furthermore, by creating your own implementation, you shield yourself against this type of version-to-version implementation changes.