像你们中的许多人一样,我使用 ReSharper 来加快开发过程。当您使用它来覆盖类的相等成员时,它生成的代码生成GetHashCode()
如下所示:
public override int GetHashCode()
{
unchecked
{
int result = (Key != null ? Key.GetHashCode() : 0);
result = (result * 397) ^ (EditableProperty != null ? EditableProperty.GetHashCode() : 0);
result = (result * 397) ^ ObjectId;
return result;
}
}
当然我也有一些我自己的成员,但我想知道为什么是 397?
- 编辑:所以我的问题的措辞会更好,397素数除了是素数之外还有什么“特殊”吗?