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

Reactions:

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Web Hosting Bluehost