Monday, January 30, 2012

Best Extension Methods: IsNullable

Below Extension method provides facility to check whether the type is nullable type or not..

   /// 
    /// Determine of specified type is nullable
    /// 
    public static bool IsNullable(Type t)
    {
        return !t.IsValueType || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>));
    }

Compiled By: Rajesh Rolen

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates