GetGenericArguments is the method you want.
if (item.PropertyType.IsGenericType) { if (item.PropertyType.GetGenericType() == typeof(Nullable<>)) { var valueType = item.PropertyType.GetGenericArguments()[0]; } }
Secondly, however, Darren's answer is much simpler in this case, as it will return null when you pass a type with a null value.
source share