Constructor Overloading in C#

Constructor Overloading

It provides several different constructor definitions with different parameter lists. It means that the number or type of arguments that is each parameter lists. This is called Constructor Overloading.

Example:

class Room
{
int length, width;
Room(int x, int y) // creating constructor 1
{
length=x;
width=y;
}
Room(int x) // creating constructor 2
{
length=width=x;
}
public int Area()
{
return(length*width);
}
}
class House
{
public static void Main()
{
Room r1=new Room(15, 10);
Room r2=new Room( 15, 0);
Console.WriteLine("Room 1 Area is: ", r1.Area());
Console.WriteLine("Room 2 Area is: ", r2.Area());
}
}

Output:
Room 1 Area is: 150
Room 2 Area is: 15