Suppose you override Object.Equals in a type, you must also
override Object.GetHashCode. If two objects are equal according
to the Equals
method, then calling GetHashCode
on each of them must yield the same integer. If this is not the case, many
collections, such as a Hashtable or a Dictionary won’t handle class instances correctly.
In order to not have unpredictable behavior, Equals
and GetHashCode
should be either both inherited, or both
overridden.