Friday, July 10, 2009

Code I love #1: IsNullOrEmpty(string)

String.IsNullOrEmpty(string)

Back in days of yore you would need to do something like

if (String.Empty) || (string = "") || (string = null)
{
//do stuff
}

Now you can cover off all those in one hit with String.IsNullOrEmpty(string).

(And yeah, code probably is probably wrong because I try not to use them since upgrading from vb6/ .net 1.0, but you get the idea :) )

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.