Here is the solution:
determine if the Type is a nullable type and if it is then call Nullable's static method GetUnderlyingTy pe()
http://msdn2.microsoft.com/en-us/lib...lyingtype.aspx
That was unbelievably hard to find out and it makes no sense that to find out what the inner type is, a static method has to analyze the nullable type. It would make more sense for a nullable type...
User Profile
Collapse
-
typeof(int?).Ba seType returns:
{Name = "ValueType" FullName = "System.ValueTy pe"} System.Type {System.Runtime Type}
typeof(int?).Ba seType.BaseType returns:
{Name = "Object" FullName = "System.Object" } System.Type {System.Runtime Type}
I have looked through all the methods and properties of the BaseType but I can't find any information about int32....Leave a comment:
-
Inner type of a Nullable type (C#)
I need to get the Inner Type of a Nullable Type (not an instance of given Nullable Type).
For example, if I have:
Type myType = typeof(int?);
How can I determine that myType has an Inner Type of System.int32?
Thanks
No activity results to display
Show More
Leave a comment: