Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain constructor.

Answer Posted / vinay tiwari

//Constructor is a special member function its name is same
//as class name.It is used to allocate memory to object and
initilizes
//its field .you can also say that it is used to initilized
the object
//constructor invoke automatically when the object of its
class is created
class a
{
public int i;
public a()//default constructor
{
i=10;
}
public a(int x)//parameterized constructor
{
i=x;
}
public a(a ob)//copy constructor
{
i=ob.i;
}
public void display()
{
System.Console.WriteLine(i);
}
}
class b
{
static void Main(string [] args)
{
a ob=new a();
ob.display();
a ob1=new a(77);
ob1.display();
a ob2=new a(ob);
ob2.display();
}
}

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of dictionary in c#?

813


Describe the difference between inline and code behind - which is best?

1024


Tell me the difference between call by value and call by reference.

921


What does string format do?

825


Explain the difference between const and static read-only?

932


What is iqueryable in linq?

824


Why we use methods in c#?

887


What are boxing and unboxing?

867


the c# keyword .int. Maps to which .net type?

1088


What does out mean c#?

880


What are destructors in C#?

1458


Why do we use interfaces in c#?

889


What are the advantages of using partial classes?

946


Can struct be static in c#?

993


What are the 2 types of data types available in c#?

836