C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String Remove()The C# Remove() method is used to get a new string after removing all the characters from specified beginIndex till given length. If length is not specified, it removes all the characters after beginIndex. Signaturepublic string Remove(Int32 beginIndex) public string Remove(Int32 beginIndex, Int32 length) Parameterindex: it is an integer type parameter. ReturnIt returns a string. C# String Remove() Method Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C#";
string s2 = s1.Remove(2);
Console.WriteLine(s2);
}
}
Output: He C# String Remove() Method Example 2
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "abcdefghijk";
string s2 = s1.Remove(4, 5);
Console.WriteLine(s2);
}
}
Output: abcdjk
Next TopicC# String Replace()
|