why do i need GetHashcode() in the IEqualityComparer interface?

i see that the IEqualityComparer interface has Equals(obj x, obj y) and GetHashcode().

I fully understand the Equals() methods because i you have to say if two things are the same or not but why do i need to implement a GetHashCode() method as well?


It's needed for use in Hashtables - it's how the container indexes your objects

http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx

链接地址: http://www.djcxy.com/p/39736.html

上一篇: .NET中的IEqualityComparer <T>中GetHashCode的作用是什么?

下一篇: 为什么我需要在IEqualityComparer接口中使用GetHashcode()?