List<T>.EnsureCapacity(Int32) Method

Definition

Ensures that the capacity of this list is at least the specified capacity. If the current capacity is less than capacity, it is increased to at least the specified capacity.

C#
public int EnsureCapacity(int capacity);

Parameters

capacity
Int32

The minimum capacity to ensure.

Returns

The new capacity of this list.

Applies to

Product Versions
.NET 6, 7, 8, 9