Enumerable.ToHashSet 方法

定義

多載

ToHashSet<TSource>(IEnumerable<TSource>)

IEnumerable<T> 建立 HashSet<T>

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

使用比較金鑰的 comparerIEnumerable<T> 建立 HashSet<T>

ToHashSet<TSource>(IEnumerable<TSource>)

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

IEnumerable<T> 建立 HashSet<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>

用來建立 HashSet<T> 的來源 IEnumerable<T>

傳回

HashSet<TSource>

HashSet<T>,包含從輸入序列選取之 TSource 類型的值。

例外狀況

sourcenull

另請參閱

適用於

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

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

使用比較金鑰的 comparerIEnumerable<T> 建立 HashSet<T>

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>

用來建立 HashSet<T> 的來源 IEnumerable<T>

comparer
IEqualityComparer<TSource>

用來比較金鑰的 IEqualityComparer<T>

傳回

HashSet<TSource>

HashSet<T>,包含從輸入序列選取之 TSource 類型的值。

例外狀況

sourcenull

另請參閱

適用於