Hello,
Substring is used if you want to extract a small portion out of the main string.
Suppose i have a string say s= "abc"; // if you say
s.Substring(start_location,number_elements_you_want);
Look at the below code:
while (true)
{
Console.WriteLine("Enter a string");
string s;
Console.WriteLine("The string you entered was : {0}", s = Console.ReadLine());
int loc; int length;
Console.WriteLine("Enter the starting location of the substring and the number of charecters in it");
Console.WriteLine(" the starting location :{0}, length:{1}", loc = int.Parse(Console.ReadLine()), length = int.Parse(Console.ReadLine()));
Console.WriteLine("The resultant is : {0}", s.Substring(loc, length));
Console.ReadLine();
}
Thanks,
Rahul