Does This String Have Anything In It? in C#

by fwhagen Wed, 04 March 2009

The following code should be failed by the C#.NET compiler:

if (eventName != null && eventName.Length > 0)

It should never be used.  People, always use this instead:

if (!String.IsNullOrEmpty(eventName))

It is much more compact, clearer, singleton, and as a String class method, more efficient.

So stop it!  You will thank me later.  Not to mention:  Where are your parentheses?  Block your code.  Other people have to read it too!

That is all.

Keywords: , ,

Filed Under: .NET | Programming | Rant

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

TextBox

RecentPosts