Getting Substrings of a given string
suggest changestring helloWorld = "Hello World!";
string world = helloWorld.Substring(6); //world = "World!"
string hello = helloWorld.Substring(0,5); // hello = "Hello"
Substring(startIndex) returns the rest of the string from that zero-based index. Substring(startIndex, length) returns length characters beginning at startIndex. The second argument is a length, not an inclusive end index.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents