System.Text.StringBuilder.Insert Method

Inserts a string into this instance at the specified character position.

Syntax

public StringBuilder Insert (int index, string value)

Parameters

index
The position in this instance where insertion begins.
value
The string to insert.

Returns

A reference to this instance after the insert operation has completed.

Exceptions

TypeReason
ArgumentOutOfRangeException

index is greater than the length of the current instance

-or-

index is less than zero.

Remarks

Existing characters are shifted to make room for the new text. The capacity is adjusted as needed.

This instance of System.Text.StringBuilder is not changed if value is null, or value is not null but its length is zero.

Requirements

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