Enumerable.ToHashSet 方法

定义

重载

ToHashSet<TSource>(IEnumerable<TSource>)

Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
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> ,其中包含从输入序列中选择的类型 TSource 值。

例外

sourcenull

另请参阅

适用于

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

Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
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> ,其中包含从输入序列中选择的类型 TSource 值。

例外

sourcenull

另请参阅

适用于