Reputation: 455
Right now, I have nullable generic type and I can check if it is nullable or not. However, I cannot find a way to get a non-nullable type from it. Here is what I want to do:
If Nullable.GetUnderlyingType(nullableType) IsNot Nothing Then
Dim nonNullableType As Type = GetNonNullableType(nullableType)
End if
For example, if nullableType is Date?, I want "GetNonNullableType" function to return Date. If it is Integer?, the function will return Integer.
Upvotes: 0
Views: 545
Reputation: 455
From Fabio suggestion, I can also Nullable.GetUnderlyingType function to get non-nullable type so it will be:
Dim nonNullableType As Type = Nullable.GetUnderlyingType(nullableType)
Upvotes: -1