แก้ไข

แชร์ผ่าน


AsyncEnumerable.DistinctBy Method

Definition

Overloads

DistinctBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>)

Returns distinct elements from a sequence according to a specified key selector function.

DistinctBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Returns distinct elements from a sequence according to a specified key selector function.

DistinctBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>)

Source:
DistinctBy.cs

Returns distinct elements from a sequence according to a specified key selector function.

public static System.Collections.Generic.IAsyncEnumerable<TSource> DistinctBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default);
static member DistinctBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function DistinctBy(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional comparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of TSource)

Type Parameters

TSource

The type of the elements of source.

TKey

The type of key to distinguish elements by.

Parameters

source
IAsyncEnumerable<TSource>

The sequence to remove duplicate elements from.

keySelector
Func<TSource,CancellationToken,ValueTask<TKey>>

A function to extract the key for each element.

comparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains distinct elements from the source sequence.

Exceptions

keySelector is null.

Remarks

This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.

The DistinctBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>) method returns an unordered sequence that contains no duplicate values. If comparer is null, the default equality comparer, Default, is used to compare values.

Applies to

DistinctBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

Source:
DistinctBy.cs

Returns distinct elements from a sequence according to a specified key selector function.

public static System.Collections.Generic.IAsyncEnumerable<TSource> DistinctBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default);
static member DistinctBy : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function DistinctBy(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), Optional comparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of TSource)

Type Parameters

TSource

The type of the elements of source.

TKey

The type of key to distinguish elements by.

Parameters

source
IAsyncEnumerable<TSource>

The sequence to remove duplicate elements from.

keySelector
Func<TSource,TKey>

A function to extract the key for each element.

comparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains distinct elements from the source sequence.

Exceptions

keySelector is null.

Remarks

This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its `GetEnumerator` method directly or by using `foreach` in Visual C# or `For Each` in Visual Basic.

The DistinctBy<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>) method returns an unordered sequence that contains no duplicate values. If comparer is null, the default equality comparer, Default, is used to compare values.

Applies to