String.TrimEnd
is the answer — trims selected characters from the end of the string only.
Note: You should pay attention to the documentation in MSDN: there was a breaking change to the behavior of this method, so the actual behavior depends on the version of .NET Framework you are targetting:
Notes to Callers
The .NET Framework 3.5 SP1 and earlier versions maintains an internal list of
white-space characters that this method trims if trimChars is null
or an empty array.
Starting with the .NET Framework 4, if trimChars is null or an empty array, the method
trims all Unicode white-space characters (that is, characters that produce a true
return value when they are passed to the Char.IsWhiteSpace
method). Because of this
change, the Trim()
method in the .NET Framework 3.5 SP1 and earlier versions removes
two characters, ZERO WIDTH SPACE (U+200B) and ZERO WIDTH NO-BREAK SPACE (U+FEFF), that
the Trim()
method in the .NET Framework 4 and later versions does not remove.
In addition, the Trim() method in the .NET Framework 3.5 SP1 and earlier versions does
not trim three Unicode white-space characters: MONGOLIAN VOWEL SEPARATOR (U+180E),
NARROW NO-BREAK SPACE (U+202F), and MEDIUM MATHEMATICAL SPACE (U+205F).