Overloading allows you to have a class that has multiple methods with the same name, but with a different number and order of arguments that accomplish a similar task. You should use overloading sparingly and only when doing so makes it easier for other developers to better understand your intentions. Furthermore, your overloaded method's behavior should be consistent across all methods that you are overloading.
The following example demonstrates overloading.
using System;
namespace Client.Chapter_5___Building_Your_Own_Classes
{
class OverloadingClasses
{
static void Main(string[] args)
{
A MyA = new A();
MyA.Display();
MyA.Display(10);
}
}
public class A
{
//Overloaded method calls
public void Display()
{
Console.WriteLine("No Params Display Method");
}
public void Display(int A)
{
Console.WriteLine("Overloaded Display {0}", A);
}
}
}