.NET BCL improvements to String.Trim

There was a requirement where we needed to make sure that some fields were not padded by tabs, any whitespace inducing characters. So I decided to have a look at String.Trim method’s documentation to see if it already tackled the problem, and how well it did.

The .NET Framework 3.5 SP1 and earlier versions maintain an internal list of white-space characters that this method trims. Starting with the .NET Framework 4, 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).

MSDN documentation

It is refreshing to know that the .NET BCL team always reviews their code so that it becomes predictable on what it will trim, and what they will not.

blog comments powered by Disqus