1

I am using a HashSet where I use instances of classes as keys, that is, the references to them. What I am unsure of, is if the HashSet will compare the references, which would mean every instance would be different, or the actual values contained in the object, which is what I need.

Does a HashSet compare by value or reference, and if it is the latter, what would be a good way to let it compare by value?

Chris Mantle
  • 6,595
  • 3
  • 34
  • 48
Aart Stuurman
  • 3,188
  • 4
  • 26
  • 44

0 Answers0