The C# SubString function is employed to extract a portion of a String. This portion begins at a designated character index and extends to the conclusion of the string.
Signature
Example
public string Substring(Int32 index)
public string Substring(Int32, Int32)
Parameter
The index parameter is an integer type value that is utilized for passing an index in order to retrieve 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