SubString(); function in C#
It is used to get a substring from a String and also it starts from the specified character position to the end of the string. In the below program I have declared 7 characters as ABCDEFG without giving any spaces in between to show you how it works and in the second line of code I have specified character position as (5) substring character its means it will start counting after the 5th position of character and will keep counting till the end and also keep in mind that its count space expressions as well.
Example
using System;
namespace program
{
class Program
{
static void Main(string[] args)
{
string str1 = "ABCDEFG";
string str2 = str1.Substring(5);
Console.WriteLine(str2);
Console.ReadKey();
}
}
}
Output
FG
It is used to get a substring from a String and also it starts from the specified character position to the end of the string. In the below program I have declared 7 characters as ABCDEFG without giving any spaces in between to show you how it works and in the second line of code I have specified character position as (5) substring character its means it will start counting after the 5th position of character and will keep counting till the end and also keep in mind that its count space expressions as well.
Example
using System;
namespace program
{
class Program
{
static void Main(string[] args)
{
string str1 = "ABCDEFG";
string str2 = str1.Substring(5);
Console.WriteLine(str2);
Console.ReadKey();
}
}
}
Output
FG