語言

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> A 包含從輸入序列中選擇的值TSource。

例外狀況

source 是 null。

適用於