我们有这两个类
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;
或者那已经有效了吗?