Something I find myself doing more and more is checking a string for empty (as in \"\" or null) and a conditional operator.
A current example:
I simply use a NullIfEmpty extension method which will always return null if the string is empty allowing ?? (Null Coalescing Operator) to be used as normal.
public static string NullIfEmpty(this string s)
{
return string.IsNullOrEmpty(s) ? null : s;
}
This then allows ?? to be used as normal and makes chaining easy to read.
string string1 = string2.NullIfEmpty() ?? string3.NullIfEmpty() ?? string4;