AsyncEnumerable.MaxAsync<TSource> 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回泛型序列中的最大值。
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)
類型參數
- TSource
元素 source的類型。
參數
- source
- IAsyncEnumerable<TSource>
一連串的數值用來決定最大值。
- comparer
- IComparer<TSource>
比較 IComparer<T> 價值。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
序列中的最大值。
例外狀況
source 是 null。
沒有任何物件 source 在 IComparableIComparable<T> or 介面(透過回傳任務)實作。
備註
若型別 TSource 實 IComparable<T>作 ,該 MaxAsync<TSource>(IAsyncEnumerable<TSource>, IComparer<TSource>, CancellationToken) 方法會利用該實作來比較值。 否則,若型別 TSource 實 IComparable作 ,則該實作用於比較值。
若 TSource 是參考型別且來源序列為空或僅包含 , null此方法會回傳 null。