We have these two classes
class Foo{
public Foo(){}
}
class FooBar : Foo{
public FooBar : base() {}
}
I know that you can see if the type of a dynamic object is something like
dynamic bar = new FooBar();
bool isType = bar is FooBar;
But how can I check if bar is of type foo?
As in
dynamic bar = new FooBar();
//This would need to check the base as well
bool isType = bar is Foo;
Or would that already work?
Yes, that will already work.
issimply checks to see if the object can be casted to the given type. See the documentaiton on it here.