Created
March 20, 2013 13:45
-
-
Save thinktainer/5204735 to your computer and use it in GitHub Desktop.
Efficient hasher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override int GetHashCode() | |
{ | |
unchecked // Overflow is fine, just wrap | |
{ | |
int hash = 17; | |
// Suitable nullity checks etc, of course :) | |
hash = hash * 23 + field1.GetHashCode(); | |
hash = hash * 23 + field2.GetHashCode(); | |
hash = hash * 23 + field3.GetHashCode(); | |
return hash; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment