1

I'm using a mix of Jon Skeet's GetHashCode and the MSDN Guidelines for Overloading Equals to implement my Equals and GetHashCode methods. However, one thing has been bothering me.

Should I implement them checking against the actual fields in the class, or their properties?

Furthermore, what about a parent class's properties with fields that are private (thus I can't access them) - should I be checking those as well, and then should I check them via their properties?

Community
  • 1
  • 1
Ricket
  • 33,368
  • 30
  • 112
  • 143

1 Answers1

1

I guess I'll make my comment an answer.

It really depends on your definition of equals on how detailed you should implement it. Properties are nothing more than over-glorified fields. I probably wouldn't hash a read-only, calculated property.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445