HashSet<T>.EnsureCapacity(Int32) Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Ensures that this hash set can hold the specified number of elements without any further expansion of its backing storage.

C#
public int EnsureCapacity(int capacity);

Parameters

capacity
Int32

The minimum capacity to ensure.

Returns

The new capacity of this instance.

Exceptions

capacity is less than zero.

Applies to

Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1