I never need to store objects in a hash table. The reason is twofold:
- coming up with a good hash function is difficult and error prone.
- an AVL tree is almost always fast enough, and it merely requires a strict order predicate, which is much easier to implement.
The Equals() operation on the other hand is a very frequently used function.
Therefore I wonder whether it is necessary to implement GetHashCode (which I never need) when implementing the Equals function (which I often need)?
my advise – if you don’t want to use it, override it and
throw new NotImplementedException();so that you will see where did you need it.