Sunday, October 28, 2012

Validation is a boxing value is default

public static bool IsDefault(this object o)
{
    if (o == null)
    {
        return true;
    }
    return (o.GetType().IsValueType)  
        ?  Activator.CreateInstance(o.GetType()).Equals(o)
        : false;
}