how to test if a given ctype is of a given template?

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

I would like to know if a type 'aType' is a Nullable<T>

With the debugger I have tried
typeof(Nullable<>).IsSubclassOf(typeof(Nullable<int>)
typeof(Nullable<int>).IsSubclassOf(typeof(Nullable<>)
typeof(Nullable<>).IsAssignableFrom(typeof(Nullable<int>)
typeof(Nullable<int>).IsAssignableFrom(typeof(Nullable<>)

They all 4 return false :S
Any tip?
 
found it:
if (ft.IsGenericType && ft.GetGenericTypeDefinition() == typeof(Nullable<>))
.......
 
Back
Top