AsyncEnumerable.ToDictionaryAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
ToDictionaryAsync<TKey,TValue>(IAsyncEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>, CancellationToken)
根據指定的金鑰比較器,從 建立 IAsyncEnumerable<T> aDictionary<TKey,TValue>。
public static System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<TKey,TValue>> ToDictionaryAsync<TKey,TValue>(this System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> source, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<'Key, 'Value>>
<Extension()>
Public Function ToDictionaryAsync(Of TKey, TValue) (source As IAsyncEnumerable(Of KeyValuePair(Of TKey, TValue)), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Dictionary(Of TKey, TValue))
類型參數
- TKey
來自元素的鍵型 source
- TValue
來自元素的值型態 source
參數
- source
- IAsyncEnumerable<KeyValuePair<TKey,TValue>>
要 IAsyncEnumerable<T> 創造一個 Dictionary<TKey,TValue> 來源。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
包含來自 source的鍵與值的 ADictionary<TKey,TValue>。
例外狀況
source 是 null。
source 包含一個或多個重複金鑰(透過回傳的任務)。
適用於
ToDictionaryAsync<TKey,TValue>(IAsyncEnumerable<ValueTuple<TKey,TValue>>, IEqualityComparer<TKey>, CancellationToken)
根據指定的金鑰比較器,從 建立 IAsyncEnumerable<T> aDictionary<TKey,TValue>。
public static System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<TKey,TValue>> ToDictionaryAsync<TKey,TValue>(this System.Collections.Generic.IAsyncEnumerable<(TKey Key, TValue Value)> source, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Collections.Generic.IAsyncEnumerable<ValueTuple<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<'Key, 'Value>>
<Extension()>
Public Function ToDictionaryAsync(Of TKey, TValue) (source As IAsyncEnumerable(Of ValueTuple(Of TKey, TValue)), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Dictionary(Of TKey, TValue))
類型參數
- TKey
來自元素的鍵型 source
- TValue
來自元素的值型態 source
參數
- source
- IAsyncEnumerable<ValueTuple<TKey,TValue>>
要 IAsyncEnumerable<T> 創造一個 Dictionary<TKey,TValue> 來源。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
包含來自 source的鍵與值的 ADictionary<TKey,TValue>。
例外狀況
source 是 null。
source 包含一個或多個重複金鑰(透過回傳的任務)。
適用於
ToDictionaryAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, Func<TSource, CancellationToken,ValueTask<TElement>>, IEqualityComparer<TKey>, CancellationToken)
根據指定的鍵選擇器與元素選擇器功能,從IAsyncEnumerable<T>「/>」建立 aDictionary<TKey,TValue>。
public static System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TSource,TKey,TElement>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TElement>> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Element>> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<'Key, 'Element>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey, TElement) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), elementSelector As Func(Of TSource, CancellationToken, ValueTask(Of TElement)), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Dictionary(Of TKey, TElement))
類型參數
- TSource
來源元素的類型。
- TKey
由 返回 keySelector的金鑰類型。
- TElement
由 返回 elementSelector的值類型。
參數
- source
- IAsyncEnumerable<TSource>
一個 IAsyncEnumerable<T> 創造一個 Dictionary<TKey,TValue> 。
- keySelector
- Func<TSource,CancellationToken,ValueTask<TKey>>
一個用來從每個元素中提取鍵值的函式。
- elementSelector
- Func<TSource,CancellationToken,ValueTask<TElement>>
一個轉換函數,從每個元素產生結果元素值。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
Dictionary<TKey,TValue> A 包含從輸入序列中選擇的值TElement。
例外狀況
elementSelector 是 null。
source 包含一個或多個重複金鑰(透過回傳的任務)。
適用於
ToDictionaryAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)
根據指定的鍵選擇器與元素選擇器功能,從IAsyncEnumerable<T>「/>」建立 aDictionary<TKey,TValue>。
public static System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TSource,TKey,TElement>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<'Key, 'Element>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey, TElement) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Dictionary(Of TKey, TElement))
類型參數
- TSource
來源元素的類型。
- TKey
由 返回 keySelector的金鑰類型。
- TElement
由 返回 elementSelector的值類型。
參數
- source
- IAsyncEnumerable<TSource>
一個 IAsyncEnumerable<T> 創造一個 Dictionary<TKey,TValue> 。
- keySelector
- Func<TSource,TKey>
一個用來從每個元素中提取鍵值的函式。
- elementSelector
- Func<TSource,TElement>
一個轉換函數,從每個元素產生結果元素值。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
Dictionary<TKey,TValue> A 包含從輸入序列中選擇的值TElement。
例外狀況
elementSelector 是 null。
source 包含一個或多個重複金鑰(透過回傳的任務)。
適用於
ToDictionaryAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource, CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>, CancellationToken)
根據指定的索引鍵選取器函式,從 Dictionary<TKey,TValue> 建立 IAsyncEnumerable<T>。
public static System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<TKey,TSource>> ToDictionaryAsync<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, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<'Key, 'Source>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Dictionary(Of TKey, TSource))
類型參數
- TSource
來源元素的類型。
- TKey
由 返回 keySelector的金鑰類型。
參數
- source
- IAsyncEnumerable<TSource>
一個 IAsyncEnumerable<T> 創造一個 Dictionary<TKey,TValue> 。
- keySelector
- Func<TSource,CancellationToken,ValueTask<TKey>>
一個用來從每個元素中提取鍵值的函式。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
包含鍵與值的 A Dictionary<TKey,TValue> 。
例外狀況
keySelector 是 null。
source 包含一個或多個重複金鑰(透過回傳的任務)。
適用於
ToDictionaryAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)
根據指定的索引鍵選取器函式,從 Dictionary<TKey,TValue> 建立 IAsyncEnumerable<T>。
public static System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<TKey,TSource>> ToDictionaryAsync<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.Dictionary<'Key, 'Source>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Dictionary(Of TKey, TSource))
類型參數
- TSource
來源元素的類型。
- TKey
由 返回 keySelector的金鑰類型。
參數
- source
- IAsyncEnumerable<TSource>
一個 IAsyncEnumerable<T> 創造一個 Dictionary<TKey,TValue> 。
- keySelector
- Func<TSource,TKey>
一個用來從每個元素中提取鍵值的函式。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
- cancellationToken
- CancellationToken
CancellationToken他們需要監控取消申請。 預設值為 None。
傳回
包含鍵與值的 A Dictionary<TKey,TValue> 。
例外狀況
keySelector 是 null。
source 包含一個或多個重複金鑰(透過回傳的任務)。