C#中的对象具有四个方法-{ Equals , GetType , ToString , GetHashCode }.br>某人可以对哈希码做什么样的有用的事情?
An object in C# has four methods - {Equals, GetType, ToString, GetHashCode}. What sort of useful thing could someone do with the hash-code?
推荐答案
某人可以对哈希码进行哪些有用的事情?
What sort of useful thing could someone do with the hashcode?
快速找到可能个相等的对象.
Quickly find potentially equal objects.
尤其是,这种方法通常由 (用于密钥)和 HashSet< T> .
In particular, this method is usually used by types such as Dictionary<TKey, TValue> (for the keys) and HashSet<T>.
您应该不假定具有相同哈希码的对象是相等的.参见 Eric Lippert的博客文章获取更多信息,而 Wikipedia哈希表页上的哈希码的使用.
You should not assume that objects with equal hash codes are equal, however. See Eric Lippert's blog post for more information, and the Wikipedia hash table page for a more general discussion on the uses of hash codes.
更多推荐
.NET对象哈希码该怎么办?
发布评论