Constructor is nothing just a method in a class which called automatically when an instance/object will create of the class...
Constructor can not be called withcout creating object of that class..
Generally Constructor are used to set initial values of class members while creating object of that class.
overloading means you can create one or more then one Constructor in a class but remember :
:- parameter datatype must be diffrent if u r creating more then one Constructor with same number of parameter.
:- parameter sequence must be diffrent if u r creating more then one Constructor with same number of parameter.
:- Number of parameter must be diffrent if u r creating more then one Constructor.
Sample Code :
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class MyClass
{
public MyClass()
{
}
public MyClass(string value1, string value2)
{
}
public MyClass(string value1, string value2, string value2)
{
}
public MyClass(int value1, int value2)
{
}
public MyClass(string value1, int value2)
{
}
public MyClass(int value1, string value2)
{
}
}