G
Guest
Said that I have the following class
Class MyRootClass(Of T)
End Class
Class MySubClass1(Of T)
Inherits MyRootClass(Of T)
End Class
Hwo can I check, at runtime, if the type of the object 'Obj' (of type
MySubClass1), is a subclass of MyRootClass?
I don't want to care about the type used by the instance/declaration of
the generic class, they can be string, integer, other object.... this
is not important for my check
I need to check the type of the generic class, independently from the
type used by the various declaration/instance of my generic class.
Dim r As New MyRootClass(Of anything1)
Dim s1 As New MySubClass1(Of anything2)
'the following code return true, this is ok
s1.GetType.GetGenericTypeDefinition.BaseType.GetGenericTypeDefinition
Is r.GetType.GetGenericTypeDefinition
'but, why the following code return FALSE?
s1.GetType.GetGenericTypeDefinition.IsSubclassOf(r.GetType.GetGenericTypeDefinition)
Why I'm unable to check inheritance of open generic type?
Thanks, adaway
Class MyRootClass(Of T)
End Class
Class MySubClass1(Of T)
Inherits MyRootClass(Of T)
End Class
Hwo can I check, at runtime, if the type of the object 'Obj' (of type
MySubClass1), is a subclass of MyRootClass?
I don't want to care about the type used by the instance/declaration of
the generic class, they can be string, integer, other object.... this
is not important for my check
I need to check the type of the generic class, independently from the
type used by the various declaration/instance of my generic class.
Dim r As New MyRootClass(Of anything1)
Dim s1 As New MySubClass1(Of anything2)
'the following code return true, this is ok
s1.GetType.GetGenericTypeDefinition.BaseType.GetGenericTypeDefinition
Is r.GetType.GetGenericTypeDefinition
'but, why the following code return FALSE?
s1.GetType.GetGenericTypeDefinition.IsSubclassOf(r.GetType.GetGenericTypeDefinition)
Why I'm unable to check inheritance of open generic type?
Thanks, adaway