StringBuilder str = new StringBuilder("This is a sample string."); string subString = str.Substring(10, 6); Console.WriteLine(subString);
StringBuilder str = new StringBuilder("Hello World!"); string subString = str.Substring(6); Console.WriteLine(subString);This will return the string "World!". As seen in the code examples, the Substring method takes in two parameters; the starting position of the extracted string and the length of the substring. However, if only the starting position is provided, the length of the substring will be the length of the original string from the starting position to the end.