Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top