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