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

public override int GetHashCode()
return _name.GetHashCode() + _address.GetHashCode();

Taking all the variables that may change the state of the object and returning their concatenated hashed values guarantees that each object will have unique values based on state. This allows objects used as keys in collections like hash tables to act in the proper manner.


Cover of Design Patterns


How to guarantee the GetHashCode() to return the unique value given a state change.