ImmutableHashSet.ToImmutableHashSet 方法

定义

重载

ToImmutableHashSet<TSource>(IEnumerable<TSource>)

枚举序列,并生成其内容的不可变哈希集。

ToImmutableHashSet<TSource>(ImmutableHashSet<TSource>.Builder)

从生成器集的当前内容创建不可变哈希集。

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

枚举序列,生成其内容的不可变哈希集,并为集类型使用指定的相等性比较器。

ToImmutableHashSet<TSource>(IEnumerable<TSource>)

Source:
ImmutableHashSet.cs
Source:
ImmutableHashSet.cs
Source:
ImmutableHashSet.cs

枚举序列,并生成其内容的不可变哈希集。

C#
public static System.Collections.Immutable.ImmutableHashSet<TSource> ToImmutableHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source);

类型参数

TSource

序列中元素的类型。

参数

source
IEnumerable<TSource>

要枚举的序列。

返回

ImmutableHashSet<TSource>

一个不可变哈希集,其中包含指定序列中的项。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableHashSet<TSource>(ImmutableHashSet<TSource>.Builder)

Source:
ImmutableHashSet.cs
Source:
ImmutableHashSet.cs
Source:
ImmutableHashSet.cs

从生成器集的当前内容创建不可变哈希集。

C#
public static System.Collections.Immutable.ImmutableHashSet<TSource> ToImmutableHashSet<TSource> (this System.Collections.Immutable.ImmutableHashSet<TSource>.Builder builder);

类型参数

TSource

哈希集中元素的类型。

参数

builder
ImmutableHashSet<TSource>.Builder

要从中创建不可变哈希集的生成器。

返回

ImmutableHashSet<TSource>

包含生成器集中的当前内容的不可变哈希集。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

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

Source:
ImmutableHashSet.cs
Source:
ImmutableHashSet.cs
Source:
ImmutableHashSet.cs

枚举序列,生成其内容的不可变哈希集,并为集类型使用指定的相等性比较器。

C#
public static System.Collections.Immutable.ImmutableHashSet<TSource> ToImmutableHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource> equalityComparer);
C#
public static System.Collections.Immutable.ImmutableHashSet<TSource> ToImmutableHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? equalityComparer);

类型参数

TSource

序列中元素的类型。

参数

source
IEnumerable<TSource>

要枚举的序列。

equalityComparer
IEqualityComparer<TSource>

用于比较集内对象相等性的对象。

返回

ImmutableHashSet<TSource>

一个不可变哈希集,该集包含指定序列中的项,并使用指定的相等性比较器。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0