Enumerable.ToHashSet 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| ToHashSet<TSource>(IEnumerable<TSource>) |
從 HashSet<T>建立 IEnumerable<T>。 |
| ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) |
使用 HashSet<T> 比較索引鍵,從 IEnumerable<T> 建立 |
ToHashSet<TSource>(IEnumerable<TSource>)
從 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<T> A 包含從輸入序列中選擇的值TSource。
例外狀況
source 是 null。
另請參閱
適用於
ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)
使用 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<T> A 包含從輸入序列中選擇的值TSource。
例外狀況
source 是 null。