In the following StackOverflow question Jon Skeets answer specifies one good implementation is ...
// Note: Not quite FNV!
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hash = (int) 2166136261;
// Suitable nullity checks etc, of course :)
hash = (hash * 16777619) ^ bool1.GetHashCode();
hash = (hash * 16777619) ^ bool2.GetHashCode();
return hash;
}
}
What if the two fields are both bools. Would this still be a good implementation or would this be overkill? If this is overkill what is the recommended approach for implementing GetHashCode
when all fields are bool types?
In my case I am only comparing two bools.