Enumerable.ToHashSet Метод
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
ToHashSet<TSource>(IEnumerable<TSource>) |
Создает HashSet<T> из IEnumerable<T>. |
ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) |
Создает HashSet<T> из IEnumerable<T> с использованием |
- Исходный код:
- ToCollection.cs
- Исходный код:
- ToCollection.cs
- Исходный код:
- 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
.
См. также раздел
Применяется к
.NET 9 и другие версии
Продукт | Версии |
---|---|
.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 |
- Исходный код:
- ToCollection.cs
- Исходный код:
- ToCollection.cs
- Исходный код:
- 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
.
См. также раздел
Применяется к
.NET 9 и другие версии
Продукт | Версии |
---|---|
.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 |
Отзыв о .NET
.NET — это проект с открытым исходным кодом. Выберите ссылку, чтобы оставить отзыв: