Why removes Tab String.Trim?

Microsoft Doc talks about String.Trim

Removes all upper and lower space characters from the current String object.

But tabs are also deleted. Is a tab character defined as a space character?
If I do not want to \tbe removed from Trim, I assume that I have to implement this myself, right?

+3
source share
3 answers

The Tab character is considered a space, but you do not need to implement it yourself. Just use overload , which contains a list of characters to trim:

char[] charsToTrim = { '*', ' ', '\''};
string banner = "*** Much Ado About Nothing ***";
string result = banner.Trim(charsToTrim);
+9
source

The tab is considered white space.

, #, .

Trim , , , , .

+3

Yes, the tab is considered white. However, Trim has an overload that accepts char[]and deletes these characters.

0
source

All Articles