相关疑难解决方法(0)

重写System.Object.GetHashCode的最佳算法是什么?

在.NET GetHashCode方法中,很多地方都使用.NET 方法.特别是在快速查找集合中的项目或确定相等性时.是否有关于如何GetHashCode为我的自定义类实现覆盖的标准算法/最佳实践,因此我不会降低性能?

.net algorithm hashcode gethashcode

1389
推荐指数
14
解决办法
19万
查看次数

自定义类型GetHashCode

可能重复:
重写的System.Object.GetHashCode的最佳算法是什么?

我需要覆盖由三个字符串组成的类型的GetHashCode方法.这是我的代码:

protected override int GetHashCode()
{
    return str1.GetHashCode() + str2.GetHashCode() + str3.GetHashCode();
}
Run Code Online (Sandbox Code Playgroud)

这种方法实现的安全方法是什么?

.net c#

10
推荐指数
1
解决办法
7733
查看次数

标签 统计

.net ×2

algorithm ×1

c# ×1

gethashcode ×1

hashcode ×1