If I do this:
Type type = typeof(Nullable<int>);
The type
variable holds the correct Nullable'1
type.
However, If I try to do this:
Nullable<int> n = 2;
Type type = n.GetType();
type
ends up holding System.Int32
which is the underlying type, but not what I am expecting.
How can I get the type of a Nullable<>
instance?
Keep in mind that I don't know the underlying type of the nullable instance, so I cannot call typeof
.