O'Reilly logo
  • Yu Sasaki thinks this is interesting:

When a hash table or other collection object indexes and compares an object, it uses the GetHashCode() method to help in this indexing and comparison. This method can be overridden to capture a more accurate sampling of the intrinsic properties or state of the object. In other words, the GetHashCode() method can return an integer representation of the concatenated state of the properties within an object. If not overridden, then this relationship is less exact. This is important when making comparisons between objects in collection classes like iterators or generic collection objects like hash tables. You need to make accurate representations of the internal state of objects so the correct object can be compared or...


Cover of Design Patterns


GetHashCode can be overridden to give an exact comparison that you want