My class structure (simplified)
interface Foo<T> { } abstract class Bar1 : Foo<SomeClass> { } abstract class Bar2 : Foo<SomeOtherClass> { } class FinalClass1 : Bar1 { } class FinalClass2 : Bar2 { }
Now, having only the type FinalClass1 and FinalClass2, I need to get the corresponding T-types from the Foo interface - SomeClass for FinalClass1 and SomeOtherClass for FinalClass2. Abstract classes can implement more general interfaces, but there is always only one Foo.
bool bIsFoo = typeof(SomeType).IsAssignableFrom(Foo<>)
The above does not work.
source share