DefaultValue

public static T DefaultValue<T>(this Nullable<T> value, T defaultValue) where T : struct
        {
            if (value == null || value.HasValue == false)
            {
                return defaultValue;
            }

            return value.Value;
        }
Example:
bool? HasVideo = null;
bool value = HasVideo.DefaultValue(false);

Description

Returns a the value of a Nullable type if it has a value or it will return a default value

Details

Double click on the code to select all.

 

;