The String class has a function "IsNullOrEmpty" which takes in a string.
http://msdn.microsoft.com/en-us/library/system.string.isnullorempty.aspx
From the documentation:
IsNullOrEmpty is a convenience method that enables you to
simultaneously test whether a String is null or its value is Empty. It
is equivalent to the following code:
result = s == null || s == String.Empty;
For example:
if (!(string.IsNullOrEmpty(person.State) && string.IsNullOrEmpty(source.State)))
{
//update your data . .
}
Alternatively you could use an extension method, similar to what is outlined by @Earlz
You can learn more about them here http://msdn.microsoft.com/en-us/library/bb383977.aspx
Therefore, assuming I had an extension method like the following:
public static bool IsBlank(this string str)
{
return string.IsNullOrEmpty(str);
}
This will allow you to do something like
if(!(person.State.IsBlank() && source.State.IsBlank())
{
//do something
}
The reason this works, even if person.State or source.State is null is because the extension method, while looking like a method of the string class, is actually converted to a static method with the string variable as it's argument (as per the documentation), so it'll happily work even if the string variable isn't set to an instance of string.
Keep in mind, though, that doing it this way could trip you up at a later time if you're reading the code and trying to figure out why it works when person.State or source.State is set to null :P
Or, y'know, alternatively I'd just write out a comparison in full :)