Language

EqualityComparer.Create Method

Definition

Overloads

Name Description
Create(Func, Func)

Creates an EqualityComparer by using the specified delegates as the implementation of the comparer's Equals(T, T) and GetHashCode(T) methods.

Create(Func, IEqualityComparer)

Create(Func, Func)

Source:
EqualityComparer.cs
Source:
EqualityComparer.cs
Source:
EqualityComparer.cs
Source:
EqualityComparer.cs

Creates an EqualityComparer by using the specified delegates as the implementation of the comparer's Equals(T, T) and GetHashCode(T) methods.

public static System.Collections.Generic.EqualityComparer Create(Func equals, Func? getHashCode = default);
static member Create : Func<'T, 'T, bool> * Func<'T, int> -> System.Collections.Generic.EqualityComparer<'T>
Public Shared Function Create (equals As Func(Of T, T, Boolean), Optional getHashCode As Func(Of T, Integer) = Nothing) As EqualityComparer(Of T)

Parameters

equals
FuncBoolean>

The delegate to use to implement the Equals(T, T) method.

getHashCode
FuncInt32>

The delegate to use to implement the GetHashCode(T) method. If no delegate is supplied, calls to the resulting comparer's GetHashCode(T) will throw NotSupportedException.

Returns

The new comparer.

Exceptions

The equals delegate was null.

Applies to

Create(Func, IEqualityComparer)

Source:
EqualityComparer.cs
public static System.Collections.Generic.EqualityComparer Create(Func keySelector, System.Collections.Generic.IEqualityComparer? keyComparer = default);
static member Create : Func<'T, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.EqualityComparer<'T>
Public Shared Function Create(Of TKey) (keySelector As Func(Of T, TKey), Optional keyComparer As IEqualityComparer(Of TKey) = Nothing) As EqualityComparer(Of T)

Type Parameters

TKey

Parameters

keySelector
Func
keyComparer
IEqualityComparer

Returns

Applies to