ImmutableHashSet.Create Method

Definition

Overloads

Create<T>()

Creates an empty immutable hash set.

Create<T>(IEqualityComparer<T>)

Creates an empty immutable hash set that uses the specified equality comparer.

Create<T>(ReadOnlySpan<T>)

Creates a new immutable collection prefilled with the specified items.

Create<T>(T)

Creates a new immutable hash set that contains the specified item.

Create<T>(T[])

Creates a new immutable hash set that contains the specified array of items.

Create<T>(IEqualityComparer<T>, ReadOnlySpan<T>)

Creates a new immutable collection prefilled with the specified items.

Create<T>(IEqualityComparer<T>, T)

Creates a new immutable hash set that contains the specified item and uses the specified equality comparer for the set type.

Create<T>(IEqualityComparer<T>, T[])

Creates a new immutable hash set that contains the items in the specified collection and uses the specified equality comparer for the set type.

Create<T>()

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

Creates an empty immutable hash set.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>();

Type Parameters

T

The type of items to be stored in the immutable hash set.

Returns

An empty immutable hash set.

Applies to

.NET 9 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0

Create<T>(IEqualityComparer<T>)

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

Creates an empty immutable hash set that uses the specified equality comparer.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T> equalityComparer);
C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T>? equalityComparer);

Type Parameters

T

The type of items in the immutable hash set.

Parameters

equalityComparer
IEqualityComparer<T>

The object to use for comparing objects in the set for equality.

Returns

An empty immutable hash set.

Applies to

.NET 9 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0

Create<T>(ReadOnlySpan<T>)

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

Creates a new immutable collection prefilled with the specified items.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(ReadOnlySpan<T> items);
C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(scoped ReadOnlySpan<T> items);

Type Parameters

T

The type of items stored by the collection.

Parameters

items
ReadOnlySpan<T>

The items to prepopulate.

Returns

The new immutable collection.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

Create<T>(T)

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

Creates a new immutable hash set that contains the specified item.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(T item);

Type Parameters

T

The type of items in the immutable hash set.

Parameters

item
T

The item to prepopulate the hash set with.

Returns

A new immutable hash set that contains the specified item.

Applies to

.NET 9 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0

Create<T>(T[])

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

Creates a new immutable hash set that contains the specified array of items.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(params T[] items);

Type Parameters

T

The type of items in the immutable hash set.

Parameters

items
T[]

An array that contains the items to prepopulate the hash set with.

Returns

A new immutable hash set that contains the specified items.

Applies to

.NET 9 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0

Create<T>(IEqualityComparer<T>, ReadOnlySpan<T>)

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

Creates a new immutable collection prefilled with the specified items.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T>? equalityComparer, ReadOnlySpan<T> items);
C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T>? equalityComparer, scoped ReadOnlySpan<T> items);

Type Parameters

T

The type of items stored by the collection.

Parameters

equalityComparer
IEqualityComparer<T>

The equality comparer.

items
ReadOnlySpan<T>

The items to prepopulate.

Returns

The new immutable collection.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)

Create<T>(IEqualityComparer<T>, T)

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

Creates a new immutable hash set that contains the specified item and uses the specified equality comparer for the set type.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T> equalityComparer, T item);
C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T>? equalityComparer, T item);

Type Parameters

T

The type of items in the immutable hash set.

Parameters

equalityComparer
IEqualityComparer<T>

The object to use for comparing objects in the set for equality.

item
T

The item to prepopulate the hash set with.

Returns

A new immutable hash set that contains the specified item.

Applies to

.NET 9 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0

Create<T>(IEqualityComparer<T>, T[])

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

Creates a new immutable hash set that contains the items in the specified collection and uses the specified equality comparer for the set type.

C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T> equalityComparer, params T[] items);
C#
public static System.Collections.Immutable.ImmutableHashSet<T> Create<T>(System.Collections.Generic.IEqualityComparer<T>? equalityComparer, params T[] items);

Type Parameters

T

The type of items stored in the immutable hash set.

Parameters

equalityComparer
IEqualityComparer<T>

The object to use for comparing objects in the set for equality.

items
T[]

An array that contains the items to prepopulate the hash set with.

Returns

A new immutable hash set that contains the specified items.

Applies to

.NET 9 and other versions
Product Versions
.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 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0