Enumerable.ToHashSet 方法

定義

多載

ToHashSet<TSource>(IEnumerable<TSource>)

來源:
ToCollection.cs
來源:
ToCollection.cs
來源:
ToCollection.cs
來源:
ToCollection.cs
來源:
ToCollection.cs

HashSet<T>建立 IEnumerable<T>

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::HashSet<TSource> ^ ToHashSet(System::Collections::Generic::IEnumerable<TSource> ^ source);
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource> source);
static member ToHashSet : seq<'Source> -> System.Collections.Generic.HashSet<'Source>
<Extension()>
Public Function ToHashSet(Of TSource) (source As IEnumerable(Of TSource)) As HashSet(Of TSource)

類型參數

TSource

元素 source的類型。

參數

source
IEnumerable<TSource>

一個 IEnumerable<T> 創造一個 HashSet<T>

傳回

HashSet<TSource>

HashSet<T> A 包含從輸入序列中選擇的值TSource

例外狀況

sourcenull

另請參閱

適用於

ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)

來源:
ToCollection.cs
來源:
ToCollection.cs
來源:
ToCollection.cs
來源:
ToCollection.cs
來源:
ToCollection.cs

使用 HashSet<T> 比較索引鍵,從 IEnumerable<T> 建立 comparer

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::HashSet<TSource> ^ ToHashSet(System::Collections::Generic::IEnumerable<TSource> ^ source, System::Collections::Generic::IEqualityComparer<TSource> ^ comparer);
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer);
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource> comparer);
static member ToHashSet : seq<'Source> * System.Collections.Generic.IEqualityComparer<'Source> -> System.Collections.Generic.HashSet<'Source>
<Extension()>
Public Function ToHashSet(Of TSource) (source As IEnumerable(Of TSource), comparer As IEqualityComparer(Of TSource)) As HashSet(Of TSource)

類型參數

TSource

元素 source的類型。

參數

source
IEnumerable<TSource>

一個 IEnumerable<T> 創造一個 HashSet<T>

comparer
IEqualityComparer<TSource>

還有 IEqualityComparer<T> 比較鑰匙。

傳回

HashSet<TSource>

HashSet<T> A 包含從輸入序列中選擇的值TSource

例外狀況

sourcenull

另請參閱

適用於