If you want to access the base implementation, you should not use overriding, you should use a new one. Override overrides any parent implementation, the new βhidesβ the parent implementation, so that you can access the implementation by casting as the parent object, then calling the method.
internal class Program { private static void Main(string[] args) { Derived d = new Derived(); d.VirtualMethod(); ((Base) d).VirtualMethod(); Console.ReadLine(); } private class Base { public virtual void VirtualMethod() { Console.WriteLine("Base virtual method"); } } private sealed class Derived : Base { public new void VirtualMethod() { Console.WriteLine("Overriden method"); } } }
This will output:
Method overcoming
Basic virtual method
Kacey source share