Questions tagged «hash-code-uniqueness»

2
为什么“ 397”用于ReSharper GetHashCode覆盖?
像你们中的许多人一样,我使用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质数以外,是否还有一些“特殊”的质数?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.