문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top