AsyncEnumerable.ToDictionaryAsync 方法

定义

重载

名称 说明
ToDictionaryAsync<TKey,TValue>(IAsyncEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>, CancellationToken)

根据指定的键比较器创建一个Dictionary<TKey,TValue>IAsyncEnumerable<T>

ToDictionaryAsync<TKey,TValue>(IAsyncEnumerable<ValueTuple<TKey,TValue>>, IEqualityComparer<TKey>, CancellationToken)

根据指定的键比较器创建一个Dictionary<TKey,TValue>IAsyncEnumerable<T>

ToDictionaryAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, Func<TSource, CancellationToken,ValueTask<TElement>>, IEqualityComparer<TKey>, CancellationToken)

根据指定的键选择器和元素选择器函数从“/Dictionary<TKey,TValue>”创建一个。IAsyncEnumerable<T>>

ToDictionaryAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)

根据指定的键选择器和元素选择器函数从“/Dictionary<TKey,TValue>”创建一个。IAsyncEnumerable<T>>

ToDictionaryAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource, CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>, CancellationToken)

根据指定的键选择器函数从 Dictionary<TKey,TValue> 创建 IAsyncEnumerable<T>

ToDictionaryAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)

根据指定的键选择器函数从 Dictionary<TKey,TValue> 创建 IAsyncEnumerable<T>

ToDictionaryAsync<TKey,TValue>(IAsyncEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>, CancellationToken)

Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs

根据指定的键比较器创建一个Dictionary<TKey,TValue>IAsyncEnumerable<T>

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

返回

ValueTask<Dictionary<TKey,TValue>>

一个包含来自 source. 的键和值的项Dictionary<TKey,TValue>

例外

sourcenull

source 包含一个或多个重复键(通过返回的任务)。

适用于

ToDictionaryAsync<TKey,TValue>(IAsyncEnumerable<ValueTuple<TKey,TValue>>, IEqualityComparer<TKey>, CancellationToken)

Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs

根据指定的键比较器创建一个Dictionary<TKey,TValue>IAsyncEnumerable<T>

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

返回

ValueTask<Dictionary<TKey,TValue>>

一个包含来自 source. 的键和值的项Dictionary<TKey,TValue>

例外

sourcenull

source 包含一个或多个重复键(通过返回的任务)。

适用于

ToDictionaryAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, Func<TSource, CancellationToken,ValueTask<TElement>>, IEqualityComparer<TKey>, CancellationToken)

Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs

根据指定的键选择器和元素选择器函数从“/Dictionary<TKey,TValue>”创建一个。IAsyncEnumerable<T>>

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

返回

ValueTask<Dictionary<TKey,TElement>>

一个 Dictionary<TKey,TValue> ,其中包含从输入序列中选择的类型 TElement 值。

例外

elementSelectornull

source 包含一个或多个重复键(通过返回的任务)。

适用于

ToDictionaryAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)

Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs

根据指定的键选择器和元素选择器函数从“/Dictionary<TKey,TValue>”创建一个。IAsyncEnumerable<T>>

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

返回

ValueTask<Dictionary<TKey,TElement>>

一个 Dictionary<TKey,TValue> ,其中包含从输入序列中选择的类型 TElement 值。

例外

elementSelectornull

source 包含一个或多个重复键(通过返回的任务)。

适用于

ToDictionaryAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource, CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>, CancellationToken)

Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs

根据指定的键选择器函数从 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

返回

ValueTask<Dictionary<TKey,TSource>>

包含键和值的 A Dictionary<TKey,TValue>

例外

keySelectornull

source 包含一个或多个重复键(通过返回的任务)。

适用于

ToDictionaryAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)

Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs
Source:
ToDictionaryAsync.cs

根据指定的键选择器函数从 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

返回

ValueTask<Dictionary<TKey,TSource>>

包含键和值的 A Dictionary<TKey,TValue>

例外

keySelectornull

source 包含一个或多个重复键(通过返回的任务)。

适用于