Tip: New .NET 4 String Function to Check for Empty Strings
How many times have you written code similar to this? string firstName = FirstName.Text.Trim(); if (!string.IsNullOrEmpty(firstName)) { // do something } or if (someParam == null || string.IsNullOrEmpty(someParam.Trim()) throw new ArgumentException(”Empty string”, “someParam”); // do something A nice little time-saver for those guard functions is now included in .NET 4: the IsNullOrWhiteSpace function: if (!string.IsNullOrWhiteSpace(FirstName.Text)) { // do something } IsNullOrWhiteSpace checks for null, empty or whitespace characters. Sure, it’s a little thing, but it’s nice to have it in there, especially considering we get all sorts of nice new little things, and the client framework install is still smaller than it was in .NET 3.5
See the original post:
Tip: New .NET 4 String Function to Check for Empty Strings


