C# Method Overriding

tutorial and example
tutorial and example

Method overriding is the mechanism where derived class defines the same method as parent class with more functionality in the chilled class. It provides runtime polymorphism in C#. It provides specific implementation to the method which is already defined in the base class.

To perform method overriding, we need to use virtual keyword for base class method and override keyword for chilled class method.

Let’s see a simple example of method overriding

Output

C# Method Overriding Example: with Multilevel inheritance:

Let’s see a simple example of method overriding with multilevel inheritance.

Output