C# Hiding, overriding and calling function from base class
When you call a virtual
method on an instance of a type that overrides the method, the overridden version will always be called, even if you cast to the base class.
The only way to call the base implementation of a virtual method on a class that overrides the method is to make a second method in the derived class (not the base class) that calls the method using the base
keyword.
In general, needing to do this is a sign of a poor API design - if you think you'll need to call the base version, the derived version should probably have a different name.
You're correct - base
can only be called from within the derived class - Source.
This page also gives an example of how to override the base class definition.
As for your second question, you are not changing the type of the object you have a reference to, just the interface you are referencing it through. So if you have an object B that inherits from A and overrides function C, even if you refer to B as an A, it still calls the implementations of the most derived type, in this case B.