The C# SubString method is used to get a substring from a String. The substring starts at a specified character position and continues to the end of the string.
Signature
Example
public string Substring(Int32 index)
public string Substring(Int32, Int32)
Parameter
index: it is an integer type parameter which is used to pass index to get a substring.
Return
It returns a string.
C# String SubString Method Example
Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C Sharp";
string s2 = s1.Substring(5);
Console.WriteLine(s2);
}
}
Output:
Output
C Sharp