AsyncEnumerable.ToHashSetAsync<TSource> 方法

定义

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

类型参数

TSource

的元素 source的类型。

参数

source
IAsyncEnumerable<TSource>

要从中创建的一 IEnumerable<T>HashSet<T>

comparer
IEqualityComparer<TSource>

要比较键的一个 IEqualityComparer<T>

cancellationToken
CancellationToken

CancellationToken 监视取消请求。 默认值为 None

返回

ValueTask<HashSet<TSource>>

一个 HashSet<T> ,其中包含从输入序列中选择的类型 TSource 值。

例外

sourcenull

适用于