How to remove first 10 characters from a string? How to remove first 10 characters from a string? asp.net asp.net

How to remove first 10 characters from a string?


str = str.Remove(0,10); Removes the first 10 characters

or

str = str.Substring(10);Creates a substring starting at the 11th character to the end of the string.

For your purposes they should work identically.


str = "hello world!";str.Substring(10, str.Length-10)

you will need to perform the length checks else this would throw an error


Substring is probably what you want, as others pointed out. But just to add another option to the mix...

string result = string.Join(string.Empty, str.Skip(10));

You dont even need to check the length on this! :) If its less than 10 chars, you get an empty string.