Enumerable.ToHashSet Metoda

Definicja

Przeciążenia

ToHashSet<TSource>(IEnumerable<TSource>)

Tworzy obiekt na HashSet<T> podstawie elementu IEnumerable<T>.

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

Tworzy obiekt HashSet<T>IEnumerable<T> na podstawie elementu comparer , aby porównać klucze.

ToHashSet<TSource>(IEnumerable<TSource>)

Źródło:
ToCollection.cs
Źródło:
ToCollection.cs
Źródło:
ToCollection.cs

Tworzy obiekt na HashSet<T> podstawie elementu IEnumerable<T>.

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

Parametry typu

TSource

Typ elementów elementu source.

Parametry

source
IEnumerable<TSource>

Element IEnumerable<T> do utworzenia elementu HashSet<T> na podstawie.

Zwraca

HashSet<TSource>

Element HashSet<T> zawierający wartości typu TSource wybrane z sekwencji danych wejściowych.

Wyjątki

source to null.

Zobacz też

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.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>)

Źródło:
ToCollection.cs
Źródło:
ToCollection.cs
Źródło:
ToCollection.cs

Tworzy obiekt HashSet<T>IEnumerable<T> na podstawie elementu comparer , aby porównać klucze.

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);

Parametry typu

TSource

Typ elementów elementu source.

Parametry

source
IEnumerable<TSource>

Element IEnumerable<T> do utworzenia elementu HashSet<T> na podstawie.

comparer
IEqualityComparer<TSource>

Element IEqualityComparer<T> do porównywania kluczy.

Zwraca

HashSet<TSource>

Element HashSet<T> zawierający wartości typu TSource wybrane z sekwencji danych wejściowych.

Wyjątki

source to null.

Zobacz też

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.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