String.IsNullOrWhiteSpace

I recently started working with Visual Studio 2010 and .NET 4.0 and I came across one of the new language features, String.IsNullWithWhiteSpace. Basically, it's an enhanced version of the commonly used String.IsNullOrEmpty. This new enhanced version goes a step forward and checks for whitespaces such as tabs.

String myString = “          “;

 

//returns false

 

Bool result = String.IsNullOrEmpty(myString);

 

//returns true

 

Bool result = String.IsNullOrWhiteSpace(myString);

A simple but convenient feature.

Print | posted on Friday, August 26, 2011 7:55 AM

Feedback

# re: String.IsNullWithWhiteSpace

left by misotor at 8/26/2011 9:49 AM Gravatar
is it IsNullOrWhiteSpace or IsNullWithWhiteSpace ? .. I sure can check it myself

# re: String.IsNullOrWhiteSpace

left by Gerardo at 8/26/2011 4:18 PM Gravatar
Sorry about the confusion. It's String.IsNullOrWhiteSpace.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: