IsNull
Essentially the implementation of the sql 'isnull' function, allowing the string type (when null) to be replaced with another value.
Source
/// <summary>
/// If the string is null, converts it to the default string specified. Essentially the same as the SQL IsNull()
/// function.
/// </summary>
/// <param name="inString"></param>
/// <param name="defaultString"></param>
/// <returns></returns>
public static string IsNull(this string inString, string defaultString)
{
if (inString==null)
return defaultString;
else return inString;
}
Example
string myString = null;
string aSaferString = myString.IsNull(string.Empty);