It looks like you have a given type for which you want either this type or its base type if it is Nullable<T>. The best way to do this would be something like this:
Nullable.GetUnderlyingType(yourObject.Type) ?? yourObject.Type;
Since it Nullabe.GetUnderlyingTypereturns nullif this is Typenot Nullable<T>, you can use the null coalescing (??) operator for the default value for the source type.
source
share