【问题标题】:Why is GetHashCode important and where can we use it? [duplicate]为什么 GetHashCode 很重要,我们可以在哪里使用它? [复制]
【发布时间】:2011-05-05 10:03:30
【问题描述】:

可能重复:
Why is it important to override GetHashCode when Equals method is overriden in C#?

为什么 GetHashCode 很重要,我们可以在哪里使用它?

【问题讨论】:

    标签: c# hashcode


    【解决方案1】:

    快速的 Google 搜索显示the MSDN documentation for Object.GetHashCode。引用:

    哈希码是一个数值,它是 用于在识别对象时 平等检验。它也可以作为 a 中对象的索引 收藏。

    GetHashCode 方法适用于 用于散列算法和数据 哈希表等结构。

    顺便说一句,如果您想自己覆盖它,请阅读该链接以及已就该主题提出的许多 SO 问题中的一些。

    【讨论】:

      猜你喜欢
      • 2014-06-01
      • 1970-01-01
      • 2019-02-20
      • 1970-01-01
      • 2019-10-17
      • 1970-01-01
      • 2015-09-02
      • 2011-07-04
      • 1970-01-01
      相关资源
      最近更新 更多