After selecting Generate > Equality members
ReSharper generates a GetHashCode()
method with body
public override int GetHashCode()
{
unchecked
{
var hashCode = (int) Property1;
hashCode = (hashCode * 397) ^ Property2;
hashCode = (hashCode * 397) ^ Property3.GetHashCode();
...
return hashCode;
}
}
according to several articles
What is the best algorithm for an overridden System.Object.GetHashCode?
https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash
I'd like to generate my own GetHashCode()
method
(inspired by first SO answer)
public override int GetHashCode()
{
unchecked
{
int hash = (int) 2166136261;
hash = (hash * 16777619) ^ Property1.GetHashCode();
hash = (hash * 16777619) ^ Property2.GetHashCode();
hash = (hash * 16777619) ^ Property3.GetHashCode();
...
return hash;
}
}
Is it possible ? How ?