Class KeyEqualityComparer<T, TKey>
Specifies the equality of objects based on the equality of a key extracted from the objects.
public class KeyEqualityComparer<T, TKey> where T : notnull where TKey : notnull
Type Parameters
TThe type of objects to compare.
TKeyThe type of the key to use to determine equality.
- Inheritance
-
objectKeyEqualityComparer<T, TKey>
- Extension Methods
Constructors
KeyEqualityComparer(Func<T, TKey>)
Specifies the equality of objects based on the equality of a key extracted from the objects.
public KeyEqualityComparer(Func<T, TKey> keySelector)
Parameters
keySelectorFunc<T, TKey>A function mapping objects to their respective equality keys.
Methods
Equals(T?, T?)
Determines whether the specified objects are equal.
public bool Equals(T? x, T? y)
Parameters
xTThe first object of type
Tto compare.yTThe second object of type
Tto compare.
Returns
- bool
true if the specified objects are equal; otherwise, false.
GetHashCode(T)
Returns a hash code for the specified object.
public int GetHashCode(T obj)
Parameters
objTThe object for which a hash code is to be returned.
Returns
- int
A hash code for the specified object.
Exceptions
- ArgumentNullException
The type of
objis a reference type andobjis null.