AsyncEnumerable.MaxAsync<TSource> Methode

Definitie

Retourneert de maximumwaarde in een algemene reeks.

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

Type parameters

TSource

Het type van de elementen van source.

Parameters

source
IAsyncEnumerable<TSource>

Een reeks waarden om de maximumwaarde van te bepalen.

comparer
IComparer<TSource>

De IComparer<T> waarden die moeten worden vergeleken.

cancellationToken
CancellationToken

De CancellationToken te controleren op annuleringsaanvragen. De standaardwaarde is None.

Retouren

ValueTask<TSource>

De maximumwaarde in de reeks.

Uitzonderingen

source is null.

Geen object in source implementeert de IComparable of IComparable<T> interface (via de geretourneerde taak).

Opmerkingen

Als het type TSource wordt geïmplementeerd IComparable<T>, gebruikt de MaxAsync<TSource>(IAsyncEnumerable<TSource>, IComparer<TSource>, CancellationToken) methode die implementatie om waarden te vergelijken. Als het type TSource wordt geïmplementeerd IComparable, wordt die implementatie gebruikt om waarden te vergelijken.

Als TSource dit een verwijzingstype is en de bronreeks leeg is of alleen waarden bevat, nullretourneert nulldeze methode .

Van toepassing op