A reference to this instance after the excise operation has completed.
Type Reason ArgumentOutOfRangeException startIndex or length is less than zero
-or-
The sum of startIndex and length is greater than the length of the current instance.
The current method removes the specified range of characters from the current instance. The characters at (startIndex + length) are moved to startIndex, and the string value of the current instance is shortened by length. The capacity of the current instance is unaffected.
The StringBuilder.Remove(int, int) method modifies the value of the current System.Text.StringBuilder instance and returns that instance. It does not create and return a new System.Text.StringBuilder object.
C# Example
using System; using System.Text; public class StringBuilderTest { public static void Main() { StringBuilder sb = new StringBuilder("0123456789"); Console.WriteLine(sb); sb.Remove(3, 4); Console.WriteLine(sb); } }
The output is
0123456789