IsNullOrDefault generic helper function for nullable types

Posted by Michael Freidgeim on Geeks with Blogs See other posts from Geeks with Blogs or by Michael Freidgeim
Published on Fri, 11 Jun 2010 23:42:18 GMT Indexed on 2010/06/11 23:53 UTC
Read the original article Hit count: 313

Filed under:
 
I've wrote  IsNullOrDefault generic helper function
 
    public  static bool IsNullOrDefault<T>(this Nullable<T> param) where T : struct
    {
        T deflt = default(T);
        if (!param.HasValue)
            return true;
        else if (param.Value.Equals(deflt))
            return true;
        return false;
    }
 

, but then realized that there is more short implementation on stackoverflow submitted by Josh
 

© Geeks with Blogs or respective owner