C# Methods Overloading

Method Overloading is a way to achieve polymorphism for methods. In Method Overloading there can be two or more methods present with the same name but having different method signatures such as return type, parameter, order of parameters, and data type of parameters.

 

 

using System;

namespace Method{
    class Program{
    
    int a = 4, b = 5;
    // First Method.
    public void sum(int a, int b){
        int sum = a + b;
        Console.WriteLine("Sum of the variables is, "+sum);
    }
    //Method Overloading.
    public int greet(){
            int sum = a + b;
            return sum;
    }
    // Main Method.
    static void Main(string[] args)
        {
            greet(4, 5);
            // Overloaded Method Calling.
            int s = greet();
            Console.WriteLine("Sum of varialbes from overloaded method is, "+s);
        }
    }
}