.Net Dictionary Hashing for Object type keys

时间:2022-05-19 16:11:27

I have a few questions regarding dictionary as below...

关于字典我有几个问题如下......

a> what algorithm is used to generate hash by the Dictionary<T1,T2> if T1 is a reference or object type.

a>如果T1是引用或对象类型,则使用什么算法通过Dictionary 生成哈希。 ,t2>

b> what collision avoiding techniques are used as part of that algorithm?

b>什么样的碰撞避免技术被用作该算法的一部分?

c> which of the following techniques are more useful to have a object class (T1) to be used as a key so that two different objects with same primitive type contents are assumed to be as the same key?

c>以下哪种技术对于将对象类(T1)用作密钥更有用,以便假设具有相同原始类型内容的两个不同对象作为相同的密钥?

  1. Overriding Equals() and GetHashCode() call?
  2. 重写Equals()和GetHashCode()调用?

  3. Implementing IEquatable<T1> interface?
  4. 实现IEquatable 接口?

  5. IEqualityComparer<T1> interface?

d> when we use LINQ lambda function .ToDictionary<>() is it necessary that the IEnumerable should be sorted on the field that is to be used as a key in the dictionary?

d>当我们使用LINQ lambda函数时.ToDictionary <>()是否必须在要用作字典中的键的字段上对IEnumerable进行排序?

1 个解决方案

#1


1  

Never mind ! I got my answer here....

没关系 !我在这里得到了答案....

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4355bcf8-3f01-4a85-b05e-bb2e829009b6/

Thx guys.

#1


1  

Never mind ! I got my answer here....

没关系 !我在这里得到了答案....

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4355bcf8-3f01-4a85-b05e-bb2e829009b6/

Thx guys.