C# String Remove(Int32)
Description
String Remove(Int32)
returns a new string in which all
the characters in the current instance, beginning at a specified position
and continuing through the last position, have been deleted.
Syntax
String.Remove(Int32)
has the following syntax.
public string Remove(
int startIndex
)
Parameters
String.Remove(Int32)
has the following parameters.
startIndex
- The zero-based position to begin deleting characters.
Returns
String.Remove(Int32)
method returns A new string that is equivalent to this string except for the removed characters.
Example
This example demonstrates the String.Remove() method.
//from w ww. j a v a 2 s.co m
using System;
class Sample
{
public static void Main()
{
string s = "abc---def";
Console.WriteLine(s);
Console.WriteLine(s.Remove(3));
Console.WriteLine(s.Remove(3, 3));
}
}
The code above generates the following result.