How to

convert value type to nullable type

Published: 23. November 2011 | Updated: 23. November 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Reflection
Tags: C# Reflection
Was this snippet helpful for you? YESYES / NONO
public static Type ConvertToNullable(Type type)
{
    if (type.IsValueType) return typeof(Nullable<>).MakeGenericType(type);
    return type;
}
Send us feedback about this snippet »



Related Snippets: