Dictionary<TKey,TValue>.EnsureCapacity(Int32) Method

Definition

Ensures that the dictionary can hold up to a specified number of entries without any further expansion of its backing storage.

C#
public int EnsureCapacity(int capacity);

Parameters

capacity
Int32

The number of entries.

Returns

The current capacity of the Dictionary<TKey,TValue>.

Exceptions

capacity is less than 0.

Applies to

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