Important Update
The Guide Feature will be discontinued after December 15th, 2023. Until then, you can continue to access and refer to the existing guides.
Author avatar

Gaurav Singhal

Overload Methods and Invoking Overloaded Methods in C#

Gaurav Singhal

  • Jul 26, 2019
  • 4 Min read
  • Jul 26, 2019
  • 4 Min read
Languages Frameworks and Tools


Method overloading is a salient feature in Object-Oriented Programming (OOP). It lets you declare the same method multiple times with different argument lists. In this guide, we are going to discuss how we can achieve method overloading in C#.


Method overloading is a form of polymorphism in OOP. Polymorphism allows objects or methods to act in different ways, according to the means in which they are used. One such manner in which the methods behave according to their argument types and number of arguments is method overloading.

Overloading happens when you have two methods with the same name but different signatures (or arguments). In a class we can implement two or more methods with the same name. Overloaded methods are differentiated based on the number and type of parameter passed as arguments to the methods. If we try to define more than one method with the same name and the same number of arguments then the compiler will throw an error.

The advantage of method overloading is that it increases code readability and maintainability. Although it is possible to have methods with the same name that perform a totally different function, it is advised that overloaded methods must have similarities in the way they perform.

Overloading Methods

It’s very easy to create a class with overloaded methods, just define methods with the same name but with different argument lists.

Method overloading can be achieved by the following:

  • By changing the number of parameters in a method

  • By changing the order of parameters in a method

  • By using different data types for parameters

Let’s look at a very common example, to find the area of any polygon.

1public class Area {
2    public double area(double s) {
3        double area = s * s;
4        return area;
5    }
7    public double area(double l, double b) {
8        double area = l * b;
9        return area;
10    }

In the above code, the method area() is defined twice. First, it's defined with one argument to find the area of the square; and second, it's defined with two arguments length and breadth, to find the area of the rectangle.,

Invoking Overloaded Methods

To invoke the overloaded methods, call the method with the exact arguments. For example, if we want to invoke the area() method to find the area of a square, we will pass only one argument.

1Area a = new Area();
2double side = 3.3;
3double square = a.area(side);



Similarly to find the area of the rectangle we would want to write the following,

1Area a = new Area();
2double length = 3.3;
3double breadth = 4.9;
4double rect = a.area(length, breadth);



Complete Source Code

1using System;
3namespace Overload_methods_and_invoke {
4    public class Area {
5        public double area(double s) {
6            double area = s * s;
7            return area;
8        }
10        public double area(double l, double b) {
11            double area = l * b;
12            return area;
13        }
14    }
16    class Program {
17        public static void Main(string[] args) {
18            Area a = new Area();
19            double length = 3.3;
20            double breadth = 4.9;
21            double rect = a.area(length, breadth);
22            Console.WriteLine("Area of rectangle " + rect);
24            double side = 3.3;
25            double square = a.area(side);
26            Console.WriteLine(square);
27        }
28    }


1Area of rectangle 16.17
2Are of square 10.89


Method overloading is a great feature for building applications that are easy to maintain. Having said that - with great power comes great responsibility - right? Too much method overloading will eventually make the code difficult to maintain for other developers. I hope you got a fair idea about method overloading. Happy coding!