Function Overloading
using System;
//Function overloading is creating several methods with the same name which differ from each other in the type of the input and the output of the function
class BaseClass
{
void display()
{
Console.WriteLine("display function with no parameter");
}
void display(int i)
{
Console.WriteLine("display function receiving integer parameter "+i);
}
void display(int i, string message)
{
Console.WriteLine("display function receiving integer parameter " + i + " and string parameter " + message);
}
static void Main(string[] args)
{
Console.WriteLine("Example of overloading");
BaseClass ch = new BaseClass();
ch.display();
ch.display(100);
ch.display(100, "hai");
Console.ReadLine();
}
}
Output:
Example of overloading
display function with no parameter
display function receiving integer parameter 100
display function receiving integer parameter 100 and string parameter hai