The new String.IsNullOrWhiteSpace method

By [)ia6l0 iii

Use the 4.0's String.IsNullOrWhiteSpace Method

This method would evaluate to true if the value is null or empty of if it has white space.  Yes, I too started by making fun of this static method on the string class.

But dwelving into the right definition threw some light at what it actually was.

"Whitespace" refers to the characters which we normarlly don't see; such as the Environment.Newline.

So effectively, a string with a value of "\n" when passed to this method would return you true.

String.IsNullOrWhiteSpace("\n") returns true.

The new String.IsNullOrWhiteSpace method  (877 Views)