ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsNullThen

Replaces NULL with the specified replacement value.

Source

public static string IsNullThen(this string str, string alt)
{
    return str ?? alt ?? string.Empty;
}

Example

string example = someString.IsNullThen("AlternateValue");

Author: Takeshi, Fukuda

Submitted on: 16 nov. 2018

Language: C#

Type: System.String

Views: 4306