«^»
8.3. Providing GetHashCode

GetHashCode is used in much the same way as hashCode in Java. Visual Studio.NET gives a warning if a class overrides Equals but does not override GetHashCode.

The Date class could provide:

public override int GetHashCode()
{
    return 0;
}

In my opinion, it would have been better if a call of object's Equals method always produces an exception. This would ensure that you would soon detect if your code calls object's Equals: this is rarely what you want to do as it does not provide you with an appropriate result. I also believe that it would have better if a call of object's GetHashCode method returns the value 0. If a class fails to provide GetHashCode, then object's GetHashCode will be used instead: returning 0 would at least do something sensible. Similar comments apply to Java.