If I never ever use HashSet, should I still implement GetHashCode?
Posted
by Dimitri C.
on Stack Overflow
See other posts from Stack Overflow
or by Dimitri C.
Published on 2010-05-27T12:32:46Z
Indexed on
2010/05/27
12:41 UTC
Read the original article
Hit count: 169
c#
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)?
© Stack Overflow or respective owner