the same name but with different parameter lists.
This enables you to create methods that perform similar tasks but operate
on different types of data or different numbers of parameters.
using System;
class Program
{
static void Main(string[] args)
{
// Call the Add method with different parameter types
Console.WriteLine("Addition of integers: " + Add(5, 7));
Console.WriteLine("Addition of doubles: " + Add(3.5, 2.5));
// Call the Add method with different numbers of parameters
Console.WriteLine("Addition of three integers: " + Add(5, 7, 10));
Console.WriteLine("Addition of four integers: " + Add(2, 3, 4, 5));
}
// Method to add two integers
static int Add(int num1, int num2)
{
return num1 + num2;
}
// Method to add two doubles
static double Add(double num1, double num2)
{
return num1 + num2;
}
// Method to add three integers
static int Add(int num1, int num2, int num3)
{
return num1 + num2 + num3;
}
// Method to add four integers
static int Add(int num1, int num2, int num3, int num4)
{
return num1 + num2 + num3 + num4;
}
}