Language

Enumerable.ToHashSet Method

Definition

Overloads

Name Description
ToHashSet(IEnumerable)

Creates a HashSet from an IEnumerable.

ToHashSet(IEnumerable, IEqualityComparer)

Creates a HashSet from an IEnumerable using the comparer to compare keys.

ToHashSet(IEnumerable)

Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs

Creates a HashSet from an IEnumerable.

public:
generic 
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::HashSet ^ ToHashSet(System::Collections::Generic::IEnumerable ^ source);
public static System.Collections.Generic.HashSet ToHashSet(this System.Collections.Generic.IEnumerable source);
static member ToHashSet : seq<'Source> -> System.Collections.Generic.HashSet<'Source>

Public Function ToHashSet(Of TSource) (source As IEnumerable(Of TSource)) As HashSet(Of TSource)

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IEnumerable

An IEnumerable to create a HashSet from.

Returns

A HashSet that contains values of type TSource selected from the input sequence.

Exceptions

source is null.

See also

Applies to

ToHashSet(IEnumerable, IEqualityComparer)

Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs
Source:
ToCollection.cs

Creates a HashSet from an IEnumerable using the comparer to compare keys.

public:
generic 
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::HashSet ^ ToHashSet(System::Collections::Generic::IEnumerable ^ source, System::Collections::Generic::IEqualityComparer ^ comparer);
public static System.Collections.Generic.HashSet ToHashSet(this System.Collections.Generic.IEnumerable source, System.Collections.Generic.IEqualityComparer? comparer);
public static System.Collections.Generic.HashSet ToHashSet(this System.Collections.Generic.IEnumerable source, System.Collections.Generic.IEqualityComparer comparer);
static member ToHashSet : seq<'Source> * System.Collections.Generic.IEqualityComparer<'Source> -> System.Collections.Generic.HashSet<'Source>

Public Function ToHashSet(Of TSource) (source As IEnumerable(Of TSource), comparer As IEqualityComparer(Of TSource)) As HashSet(Of TSource)

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IEnumerable

An IEnumerable to create a HashSet from.

comparer
IEqualityComparer

An IEqualityComparer to compare keys.

Returns

A HashSet that contains values of type TSource selected from the input sequence.

Exceptions

source is null.

See also

Applies to