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

Or

Returns the first string with a non-empty non-null value.

Source

public static string Or(this string input, string alternative)
{
    return (string.IsNullOrEmpty(input)==false) ? input : alternative;
}

Example

string someResult = someString1.Or(someString2).Or("foo");

Author: Phil Campbell

Submitted on: 25 okt 2013

Language: C#

Type: System.String

Views: 3628