Google Guava provides nice helpers to implement equals and hashCode like the following example demonstrates:
public int hashCode() {
return Objects.hashCode(lastName, firstName, gender);
}
Is there a similar library for Microsoft .NET?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t see why you’d need one. If you want to create a hash-code based on the default
GetHashCodefor 3 different items, then just use:That’ll boil down to the equivalent of:
Which is pretty reasonable for such a general-purpose combination.
Likewise:
Would boil down to the equivalent of calling:
Again, about as good as you could expect.