How do I convert a System.Type to its nullable version?
- by AlexDuggleby
Once again one of those: "Is there an easier built-in way of doing things instead of my helper method?"
So it's easy to get the underlying type from a nullable type, but how do I get the nullable version of a .NET type?
So I have
typeof(int)
typeof(DateTime)
System.Type t = something;
and I want
int?
DateTime?
or
Nullable<int> (which is the same)
if t is primitive then Nullable<T> else just T
Any suggestions? (Is there something built in.)
Thanks in advance.