Dennis Korbar wrote:I'm not sure if there is a way to check it before, but how about this workaround?
If I were your employer and you would hand in that code, I would fire you on the spot. Seriously. Well ok, maybe not fire you, but definitely yell at you.
Classes should never need to know anything about which sub classes it has, and your workaround clearly violates that.