zq5-1g
Last Updated: February 25, 2016
·
677
· 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

11816

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 ·