在.NET GetHashCode方法中,很多地方都使用.NET 方法.特别是在快速查找集合中的项目或确定相等性时.是否有关于如何GetHashCode为我的自定义类实现覆盖的标准算法/最佳实践,因此我不会降低性能?
我需要覆盖由三个字符串组成的类型的GetHashCode方法.这是我的代码:
protected override int GetHashCode()
{
return str1.GetHashCode() + str2.GetHashCode() + str3.GetHashCode();
}
Run Code Online (Sandbox Code Playgroud)
这种方法实现的安全方法是什么?