IEquality Comparer

Job offer
February 9, 2017
REST
May 26, 2017

 

IEqualityComparer (https://msdn.microsoft.com/en-us/library/ms132151(v=vs.110).aspx) is interface which defines methods for object comparation. IEqualityComparer can be used for comparation of Dictionary Collections.
Equals is methid which compares 2 object values. If they are equal it will return true, else it will return false.

GetHashCode(https://msdn.microsoft.com/en-us/library/system.object.gethashcode(v=vs.110).aspx) is method which return interger hash code of particular object. This is basicaly object memory address. If hash values of 2 object are the same, then comparer will return value true. Hash code should be unique until end of object lifetime. This is reason why values for which we need hash values need to be Immutable.

Example:

 

 

Milena Tošović

Senior Developer