Last Updated: February 25, 2016
·
832
· tylerfowler

Checking if a String is Null or Empty in .NET (C#)

Nifty little method built into the .NET String class that is cleaner than checking for both conditions.

if (String.IsNullOrEmpty(stringVal))
    /* do stuff */

1 Response
Add your response

I have used the string.IsNullOrWhiteSpace() method. It is a little bit more aggressive and checks if the string contains white-space characters.

over 1 year ago ·