0

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.

Pawich S.
  • 375
  • 6
  • 20
  • 1
    Are you talking about `Type` or `Value`? `Nullable.GetUnderlyingType` will return underlying type (If Date? - return Date). Why you cannot use it? – Fabio Jun 18 '16 at 06:36
  • Ah. Thank you for pointing out. I just don't really know how this function works. The reason I know the way how to check if it is null or not because I just searched through the internet and copy to my code. You can downvote my stupid question -_-" – Pawich S. Jun 18 '16 at 07:02

1 Answers1

-1

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)
Pawich S.
  • 375
  • 6
  • 20