I have many classes.
public abstract class ClassA {}
public class ClassB : ClassA {}
public class ClassC : ClassA {}
public class ClassD : ClassB {}
public class ClassE : ClassB {}
public class ClassF : ClassC {}
public class ClassG : ClassC {}
I have an object that is typed as ClassA. I want to check if this object is an instance of ClassB or not, when it is actually an instance of D, E, F or G. Basically test if it is B, D or E, by checking if it inherits B or is B.
if (obj.GetType == typeof(ClassB)) returns false when ClassD or ClassE.
What should I do in that situation without explicitly checking for every single type that inherits from B?