Or

public static T Or<T>(this T t, params T[] args)
{
    foreach (var item in args)
        if (item != null) return item;
    return default(T);
}
Example:
string s = GetValue(); // s == null
Console.WriteLine(s.Or("value not found")):

Description

Returns the object if it's not null or the first object which is not null.

Details

Double click on the code to select all.

 

;