System.Text.StringBuilder.EnsureCapacity Method

Ensures that the capacity of this instance of System.Text.StringBuilder is at least the specified value.

Syntax

public int EnsureCapacity (int capacity)

Parameters

capacity
The minimum capacity to ensure.

Returns

The new capacity of this instance.

Exceptions

TypeReason
ArgumentOutOfRangeException capacity is less zero.

Remarks

If the current capacity is less than the capacity parameter, memory for this instance is reallocated to hold at least capacity number of characters; otherwise, no memory is changed.

Requirements

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0