Lets say that we have the following code
Base() { ... }
Derived : Base { ... }
Main()
{
var derivedInstance = new Derived();
if(derivedInstance is Base)
{
DoStuff();
}
}
The if statement that we have returns true. How do I differentiate between the derived type from the base type when I am working with a derived instance.
Essentially, I want the above if statement to return false, but not sure how to accomplish this.
Try
However, this looks rather strange. What are you trying to do?
What about having a virtual method defined in your base class:
And then you could just call
DoStuff()on the instance, without checking its type.