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 */
Written by Tyler Fowler
Related protips
1 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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#