I want to compare strings that come from two different sources. If they are different, I will do something. More or less like this:
if (foo != bar)
{
noop();
}
However, in my specific case, I am considering that an empty string and a null string are the same thing. In some languages such as Javascript such a code would suffice, but that's not the way it works in the .NET world ...
string foo = null;
string bar = "";
foo == bar; // false;
I know I can solve my problem with some preconversion of type:
foo = (foo != null ? foo : "");
bar = (bar != null ? bar : "");
But this bothers me, because it seems excessive. Is there a more minimalist way of making a comparison that considers null or void the same thing?