Language

AsyncEnumerable.MaxByAsync Method

Definition

Overloads

Name Description
MaxByAsync(IAsyncEnumerable, Func, IComparer, CancellationToken)

Returns the maximum value in a generic sequence according to a specified key selector function.

MaxByAsync(IAsyncEnumerable, Func>, IComparer, CancellationToken)

Returns the maximum value in a generic sequence according to a specified key selector function.

MaxByAsync(IAsyncEnumerable, Func, IComparer, CancellationToken)

Source:
MaxByAsync.cs
Source:
MaxByAsync.cs
Source:
MaxByAsync.cs
Source:
MaxByAsync.cs

Returns the maximum value in a generic sequence according to a specified key selector function.

public static System.Threading.Tasks.ValueTask MaxByAsync(this System.Collections.Generic.IAsyncEnumerable source, Func keySelector, System.Collections.Generic.IComparer? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member MaxByAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>

Public Function MaxByAsync(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), Optional comparer As IComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)

Type Parameters

TSource

The type of the elements of source.

TKey

The type of key to compare elements by.

Parameters

source
IAsyncEnumerable

A sequence of values to determine the maximum value of.

keySelector
Func

A function to extract the key for each element.

comparer
IComparer

The IComparer to compare keys.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The value with the maximum key in the sequence.

Exceptions

source is null.

No key extracted from source implements the IComparable or IComparable interface.

Remarks

If TKey is a reference type and the source sequence is empty or contains only values that are null, this method returns null.

Applies to

MaxByAsync(IAsyncEnumerable, Func>, IComparer, CancellationToken)

Source:
MaxByAsync.cs
Source:
MaxByAsync.cs
Source:
MaxByAsync.cs
Source:
MaxByAsync.cs

Returns the maximum value in a generic sequence according to a specified key selector function.

public static System.Threading.Tasks.ValueTask MaxByAsync(this System.Collections.Generic.IAsyncEnumerable source, Func> keySelector, System.Collections.Generic.IComparer? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member MaxByAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>

Public Function MaxByAsync(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional comparer As IComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)

Type Parameters

TSource

The type of the elements of source.

TKey

The type of key to compare elements by.

Parameters

source
IAsyncEnumerable

A sequence of values to determine the maximum value of.

keySelector
FuncCancellationToken,ValueTask>

A function to extract the key for each element.

comparer
IComparer

The IComparer to compare keys.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The value with the maximum key in the sequence.

Exceptions

source is null.

No key extracted from source implements the IComparable or IComparable interface.

Remarks

If TKey is a reference type and the source sequence is empty or contains only values that are null, this method returns null.

Applies to