Checking a string for null or empty string
Jeff Key
Thursday, April 01, 2004
Comments

Cheap trick:

Convert.ToString((object)stringVar) == “”

This works because Convert.ToString(object) returns an empty string if object is null.  Convert.ToString(string) returns null if string is null.

(Or, if you're using .NET 2.0 you could always using String.IsNullOrEmpty.)


You might also be interested in my .NET development tools, samples, etc. (All free, of course!)