IsDefaultForType

public static bool IsDefaultForType<T>(this T val)
{
    return EqualityComparer<T>.Default.Equals(val, default(T));
}
Example:
var obj = SomeComplexFunction();

if(obj.IsDefaultForType())
{
    RunSomethingElse();
}

Description

Returns true or false depending on if the given object is equal to the default(T) value of the type.

Details

Double click on the code to select all.

 

;