Microsoft Doc says about String.Trim
Removes all leading and trailing white-space characters from the current String object.
But tabulator characters get removed too. Is tabulator defined as whitespace character?
If I don't want \t
to be removed from Trim
I guess I have to implement that myself, right?
The Tab character is considered whitespace, but you don't have to implement it yourself. Just use the overload that takes a list of characters to trim:
char[] charsToTrim = { '*', ' ', '\''};
string banner = "*** Much Ado About Nothing ***";
string result = banner.Trim(charsToTrim);