A while ago, I bumped into a situation where someone had tried to solve the problem below with a convoluted reflection based solution for this seemingly simple problem:
class A {}
class B : A {}
B b = new B();
if(b is A) // this should return false
And indeed the solution is simple: replace the “b is a” with this:
b.GetType() == typeof(A)
Thanks StackOverflow users ChaosPandion and John K.
–jeroen





