Enumerable.ToHashSet Metodo

Definizione

Overload

ToHashSet<TSource>(IEnumerable<TSource>)

Crea un oggetto HashSet<T> da un oggetto IEnumerable<T>.

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

Crea un oggetto HashSet<T> da un oggetto IEnumerable<T> usando comparer per confrontare le chiavi.

ToHashSet<TSource>(IEnumerable<TSource>)

Origine:
ToCollection.cs
Origine:
ToCollection.cs
Origine:
ToCollection.cs

Crea un oggetto HashSet<T> da un oggetto IEnumerable<T>.

C#
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source);

Parametri di tipo

TSource

Tipo degli elementi di source.

Parametri

source
IEnumerable<TSource>

Oggetto IEnumerable<T> da cui creare un oggetto HashSet<T>.

Restituisce

HashSet<TSource>

Oggetto HashSet<T> che contiene valori di tipo TSource selezionati dalla sequenza di input.

Eccezioni

source è null.

Vedi anche

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7.2, 4.8, 4.8.1
.NET Standard 2.1

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

Origine:
ToCollection.cs
Origine:
ToCollection.cs
Origine:
ToCollection.cs

Crea un oggetto HashSet<T> da un oggetto IEnumerable<T> usando comparer per confrontare le chiavi.

C#
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer);
C#
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource> comparer);

Parametri di tipo

TSource

Tipo degli elementi di source.

Parametri

source
IEnumerable<TSource>

Oggetto IEnumerable<T> da cui creare un oggetto HashSet<T>.

comparer
IEqualityComparer<TSource>

Oggetto IEqualityComparer<T> per confrontare le chiavi.

Restituisce

HashSet<TSource>

Oggetto HashSet<T> che contiene valori di tipo TSource selezionati dalla sequenza di input.

Eccezioni

source è null.

Vedi anche

Si applica a

.NET 9 e altre versioni
Prodotto Versioni
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7.2, 4.8, 4.8.1
.NET Standard 2.1