Enumerable.ToHashSet 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| ToHashSet<TSource>(IEnumerable<TSource>) |
从 HashSet<T>创建 IEnumerable<T>。 |
| ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) |
使用 HashSet<T> 比较键从 IEnumerable<T> 创建 |
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<T> ,其中包含从输入序列中选择的类型 TSource 值。
例外
source 是 null。
另请参阅
适用于
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<T> ,其中包含从输入序列中选择的类型 TSource 值。
例外
source 是 null。