What is the method overloading in C#?

Image result for what is method overloading in c#
Two or more than two methods having the same name but different parameters is what we call method overloading in C#.
Method overloading in C# can be performed by changing the number of arguments and the data type of the arguments.
Let’s say you have a function that prints multiplication of numbers, then our overloaded methods will have the same name but different number of arguments 
using System;  
public class Demo {  
   public static int mulDisplay(int one, int two) {  
      return one * two;  
   }  

   public static int mulDisplay(int one, int two, int three) {  
      return one * two * three;  
   }  

   public static int mulDisplay(int one, int two, int three, int four) {  
      return one * two * three * four;  
   }  
}  

public class Program {  
   public static void Main() {  
      Console.WriteLine("Multiplication of two numbers: "+Demo.mulDisplay(10, 15));  
      Console.WriteLine("Multiplication of three numbers: "+Demo.mulDisplay(8, 13, 20));  
      Console.WriteLine("Multiplication of four numbers: "+Demo.mulDisplay(3, 7, 10, 7)); 


Comments