VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/method-overloading-in-c-sharp/

⇱ Method Overloading in C# - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Method Overloading in C#

Last Updated : 20 Feb, 2026

Method Overloading in C# is the ability to define multiple methods with the same name but different parameter lists.

  • Parameter lists can differ by type, number or order of parameters.
  • Improves readability and lets related tasks use the same method name.
  • Cannot overload methods by only changing the return type (causes compile-time error).
  • Also known as compile-time (static) polymorphism.

Different Ways of Method Overloading

Method overloading can be done by changing:

  • Changing the number of Parameters
  • Changing data types of the parameters.
  • Changing the Order of the parameters.

1. Changing the number of Parameters

We can achieve method overloading by changing the number of parameters of a method.

Example: Overloading by changing the Number of parameters


Output
add() with two integers
sum: 3
add() with three integers
sum: 6

2. Changing the Data types of the parameters

We can achieve method overloading by changing the data type of the method's parameter.

Example: Overloading by changing the Data types of the parameters


Output
Add() with integer parameter
sum: 6
Add() with double parameter
sum: 6

3. Changing the Order of the parameters

If the method has the same name but a parameters order of parameters so in this way we can also achieve the method overloading.

Example:


Output
Name1 : Geek, Id1 : 1
Name2 : Geek2, Id2 : 2

Example: In this example, we understand what happens when the method signature is the same and the return type is different

Output:

👁 ErrorInOverriding
Output

Explanation: The compiler will give an error as the return value alone is not sufficient for the compiler to figure out which function it has to call. Only if both methods have different parameter types (so, they have different signatures), then Method overloading is possible.

Comment
Article Tags:

Explore