我们有这两个类
class Foo{
public Foo(){}
}
class FooBar : Foo{
public FooBar : base() {}
}
我知道您可以查看动态对象的类型是否类似于
dynamic bar = new FooBar();
bool isType = bar is FooBar;
但是如何检查 bar 是否为 foo 类型?
如在
dynamic bar = new FooBar();
//This would need to check the base as well
bool isType = bar is Foo;
或者这已经奏效了?