Enumerable.ToHashSet 方法
定義
多載
ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) |
使用比較金鑰的 |
ToHashSet<TSource>(IEnumerable<TSource>) |
從 IEnumerable<T> 建立 HashSet<T>。Creates a HashSet<T> from an IEnumerable<T>. |
ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)
使用比較金鑰的 comparer
從 IEnumerable<T> 建立 HashSet<T>。Creates a HashSet<T> from an IEnumerable<T> using the comparer
to compare keys.
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
項目的類型。The type of the elements of source
.
參數
- source
- IEnumerable<TSource>
用來建立 HashSet<T> 的來源 IEnumerable<T>。An IEnumerable<T> to create a HashSet<T> from.
- comparer
- IEqualityComparer<TSource>
用來比較金鑰的 IEqualityComparer<T>。An IEqualityComparer<T> to compare keys.
傳回
- HashSet<TSource>
HashSet<T>,包含從輸入序列選取之 TSource
類型的值。A HashSet<T> that contains values of type TSource
selected from the input sequence.
適用於
ToHashSet<TSource>(IEnumerable<TSource>)
從 IEnumerable<T> 建立 HashSet<T>。Creates a HashSet<T> from an 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
項目的類型。The type of the elements of source
.
參數
- source
- IEnumerable<TSource>
用來建立 HashSet<T> 的來源 IEnumerable<T>。An IEnumerable<T> to create a HashSet<T> from.
傳回
- HashSet<TSource>
HashSet<T>,包含從輸入序列選取之 TSource
類型的值。A HashSet<T> that contains values of type TSource
selected from the input sequence.