Method Overloading vs Overriding


In this article we are going to discuss difference between Method Overloading and Overriding in C#. There are many blogs, articles are available on the internet regarding it but in this particular article I will try to explain to you with as much as simplest and realistic examples so you can get a clear idea of the Method Overloading and Overriding in C#.

1. Method Overloading

Method overloading allows multiple methods in the same class to have the same name but different parameters (either in type or number and order of parameters).

Some Important points related to Method Overloading:

  1. Multiple methods of same name in single class.
  2. No need of inheritance, as it is in single class.
  3. All methods have different signature.
  4. It’s a compile time polymorphism.
  5. No special keyword used.

2. Method Overriding

Method overriding allows a subclass to provide a specific implementation of a method that is already defined in its superclass. we can also say Overriding is used to modify and provide a new implementation of the method inherited from a base class. Some Important points related to Method Overriding:

  1. Multiple methods of same name in different class.
  2. Inheritance is used, as it is in different class.
  3. All methods have same signature.
  4. It’s a run time polymorphism.
  5. Virtual & override keywords.

Difference Between Method Overloading and Overriding in C#

S.No. Method Overloading Method Overriding
1 Multiple methods of same name in single class. Multiple methods of same name in different class.
2 No need of inheritance, as it is in single class. Inheritance is used, as it is in different class.
3 All methods have different signature. All methods have same signature.
4 It’s a compile time polymorphism. It’s a run time polymorphism.
5 No special keyword used. Virtual & override keywords.

Next