IsNull

	/// <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);

Description

Essentially the implementation of the sql 'isnull' function, allowing the string type (when null) to be replaced with another value.

Details

Double click on the code to select all.

 

;