Skip to main content
2 of 2
edited body
Oded
  • 500.7k
  • 102
  • 900
  • 1k

C# .NET GetHashCode function question

Hi I have a class with 6 string properties. A unique object will have different values for atleast one of these fields

To implement IEqualityComparer's GetHashCode function, I am concatenating all 6 properties and calling the GetHashCode on the resultant string.

I had the following doubts:

  1. Is it necessary to call the GetHashcode on a unique value?
  2. Will the concatenation operation on the six properties make the comparison slow?
  3. Should I use some other approach?
ganeshran
  • 3.5k
  • 7
  • 46
  • 71