I have:
class A
class B : A
class C : B
class D : B
And I have a List
Where actual objects of C and D are stored.
How can I check whether the objects in List is a subtype of B?
Currently, I'm doing item.GetType() == typeof(C) || item.GetType() == typeof(D)
This works, but what if I had more than 2 classes that are inherited from B? Writing all of them down seems redundant. Is there a way to check whether the object is a subtype of B? Thanks!