I have a string say
"Hello! world!"
I want to do a trim or a remove to take out the ! off world but not off Hello.
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.
read more
EDIT:
What I’ve noticed in this type of questions that quite everyone suggest to remove the last char of given string. But this does not fulfill the definition of Trim method.
MSDN-Trim
Under this definition removing only last character from string is bad solution.
So if we want to “Trim last character from string” we should do something like this
Example as extension method:
Note if you want to remove all characters of the same value i.e(!!!!)the method above removes all existences of ‘!’ from the end of the string,
but if you want to remove only the last character you should use this :