System.String.Remove Method

Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.

Syntax

public string Remove (int startIndex, int count)

Parameters

startIndex
The zero-based position to begin deleting characters.
count
The number of characters to delete.

Returns

A new string that is equivalent to this instance except for the removed characters.

Exceptions

TypeReason
ArgumentOutOfRangeException

startIndex or count is less than zero.

-or-

startIndex plus count is greater than the length of the current instance.

Remarks

In the dnprdnshort, strings are zero-based. The value of the startIndex parameter can range from zero to one less than the length of the string instance.

Note:

This method does not modify the value of the current instance. Instead, it returns a new string in which the number of characters specified by the count parameter have been removed. The characters are removed at the position specified by startIndex.

Requirements

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