Eric's Blog

Day to day experience in .NET
Welcome to Blogs @ IRM Sign in | Join | Help
 Search

Disclaimer

The content of this site is my own personal opinion and does not in any way represent my employer, it's subsideries or affiliates. These postings are provided "AS IS" with no warranties, and confer no rights.

This Blog

The Small Things: string.IsNullOrEmpty

Visual Studio 2005 has arrived and with it the new much improved .NET Framework 2.0. Now as it is here we (I believe I can talk for everyone on this matter) have a huge challenge to learn about all the new stuff, and not continue to do things as we always have. Speaking for myself, I can feel that during the last five years (I can't believe that five years have passed by since I started to use .NET on a regularly base, preparing new course material for courses on Beta 1) I have started to solve problems, big and small, in a certain way that the previous (1.1) platform supported. Now is the time to break some of this habits.
Magazines and different web pages will write a lot about all the great new stuff as Membership functionallity and so on, but no one writes about this small beautiful things that also will affect your day to day programming i .NET. But with this first post, I hope that I will be able to, every now and then, write some shorter blogs about new stuff (or new habits). I will not say that they always will be short and for small things, but I will not hesitate to write about them.
 
The first one will be one of my new favorites: string.IsNullOrEmpty. How many of you have written an if-statement simillar to this one:
 
if (arg == null || arg.Length == 0) throw new ArgumentNullException("arg");
 
If you have, then stop doing it now and instead use:
 
if (string.IsNullOrEmpty(arg)) throw new ArgumentNullException("arg");
Published den 31 oktober 2005 20:54 by ericqu

Comments

No Comments
New Comments to this post are disabled
Powered by Community Server, by Telligent Systems