I have a string like this:
“/AuditReport”
It is assigned to variable rep.
If I type
var r = rep.SysName.Remove(1, 1);
It returns “/uditReport” instead of desired “AuditReport”,
i.e. it does not remove the slash. How could I remove it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
String indices in .NET are zero-based. The documentation for
Removestates that the first argument is “The zero-based position to begin deleting characters”.Alternatively, using
Substringis more readable, in my opinion:Or, you could possibly use
TrimStart, depending on your requirements. (However, note that if your string starts with multiple successive slashes thenTrimStartwill remove all of them.)