Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0237 Get the substring

SubString returns the substring from the current. Specify only the start position using System; class Sample { public static void Main() { string s = "rntsoft.com"; Console.WriteLine(s.Substring(2)); } } The output: tsoft.com Specify both the start and end using System; class Sample { public static void Main() { string s = "rntsoft.com"; Console.WriteLine(s.Substring(2, 3)); } } The output: tso