Reputation: 34087
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?
Upvotes: 1
Views: 85
Reputation: 191036
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.
Upvotes: 1