Clever-1945
12/1/2017 - 5:07 AM

T в Nullable_T #CSharp

T в Nullable_T #CSharp

//Преобразование типа из T в Nullable<T>
Type GetNullableType(Type type) {
    // Use Nullable.GetUnderlyingType() to remove the Nullable<T> wrapper if type is already nullable.
    type = Nullable.GetUnderlyingType(type);
    if (type.IsValueType)
        return typeof(Nullable<>).MakeGenericType(type);
    else
        return type;
}