Author: you've been HAACKED | Posted on: 6/17/2010 12:35:49 AM | Views : 858

In my last blog post, I wrote about the proper way to check for empty enumerations and proposed an IsNullOrEmpty method for collections which sparked a lot of discussion. This post covers a similar issue, but from a different angle. A very long time ago, I wrote about my love for the null coalescing operator . However, over time, I've found it to be not quite as useful as it could be when dealing with strings. For example, here's the code I might want to write: public static void DoSomething( string argument) { var theArgument = argument ?? "defaultValue" ; Console.WriteLine(theArgument); } But here's the code I actually end up writing: public static void DoSomething( string argument) { var theArgument = argument; if (String.IsNullOrWhiteSpace...(read more) ...

Go to the complete details ...