Method overriding is done through inheritance, it allows us to define a method at a derived class with the same name present in a base class with the same signature and same return type then the method in a base class is said to be overridden.
In method overriding, the base class method uses virtual keyword while the derived class method uses override keyword.
Method overriding is one of the ways through which C# achieves Run Time Polymorphism (Dynamic Polymorphism). The decision made to call the required function is done at the run time. Hence, it is a Runtime polymorphism.
Example: C# program for method overriding.
public class Animal
public virtual void sleep()
public class Dog: Animal //inheriting Animal class
public override void sleep()
public class OverrideMain
public static void Main()
Animal obj = new Dog();
obj = new Animal();