If you have a number of strings that you need to trim whitespaces from, however I only need to remove them from the end. They are being used for company and individual names, so it’s ok for there to be spaces in the middle of the string.

You could just use Trim() or if you just want to apply to just the end TrimEnd()

C# Trim() is a string method. This method is commonly used to removes all leading and trailing whitespace characters from the current String object.

5/5 - (2 votes)