語言

AsyncEnumerable.MaxByAsync 方法

定義

多載

名稱 Description
MaxByAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>, CancellationToken)

根據指定的索引鍵選取器函式,傳回泛型序列中的最大值。

MaxByAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IComparer<TKey>, CancellationToken)

根據指定的索引鍵選取器函式,傳回泛型序列中的最大值。

MaxByAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>, CancellationToken)

來源:
MaxByAsync.cs
來源:
MaxByAsync.cs
來源:
MaxByAsync.cs
來源:
MaxByAsync.cs

根據指定的索引鍵選取器函式,傳回泛型序列中的最大值。

public static System.Threading.Tasks.ValueTask<TSource?> MaxByAsync<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IComparer<TKey>? 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>
<Extension()>
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)

類型參數

TSource

元素 source的類型。

TKey

比較元素的鑰匙類型。

參數

source
IAsyncEnumerable<TSource>

一連串的數值用來決定最大值。

keySelector
Func<TSource,TKey>

一個用來提取每個元素鍵值的函式。

comparer
IComparer<TKey>

比較 IComparer<T> 鑰匙。

cancellationToken
CancellationToken

CancellationToken他們需要監控取消申請。 預設值為 None。

傳回

ValueTask<TSource>

序列中鍵數最大值。

例外狀況

source 是 null。

從 source or 介面擷取的金鑰都無法實現IComparable。IComparable<T>

備註

若 TKey 是參考型別且來源序列為空或僅包含 , null此方法會回傳 null。

適用於

MaxByAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IComparer<TKey>, CancellationToken)

來源:
MaxByAsync.cs
來源:
MaxByAsync.cs
來源:
MaxByAsync.cs
來源:
MaxByAsync.cs

根據指定的索引鍵選取器函式,傳回泛型序列中的最大值。

public static System.Threading.Tasks.ValueTask<TSource?> MaxByAsync<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, System.Collections.Generic.IComparer<TKey>? 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>
<Extension()>
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)

類型參數

TSource

元素 source的類型。

TKey

比較元素的鑰匙類型。

參數

source
IAsyncEnumerable<TSource>

一連串的數值用來決定最大值。

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

一個用來提取每個元素鍵值的函式。

comparer
IComparer<TKey>

比較 IComparer<T> 鑰匙。

cancellationToken
CancellationToken

CancellationToken他們需要監控取消申請。 預設值為 None。

傳回

ValueTask<TSource>

序列中鍵數最大值。

例外狀況

source 是 null。

從 source or 介面擷取的金鑰都無法實現IComparable。IComparable<T>

備註

若 TKey 是參考型別且來源序列為空或僅包含 , null此方法會回傳 null。

適用於