Pages

Thursday, September 8, 2011

Why Trim() function ignore specified characters?

Trim() function in String will trim the preceding and trailing characters of a given character array until it finds a character which is not there in the given array.

Example:
char[] t = new char[] { 1, 2, 3}

trim("12external319test23");

result is "external319test".

So, if it is posible to have spaces, commas etc. as leading or trailing characters in addition to the defined character set, add them also to the character array, before you call Trim() function.

No comments:

Post a Comment