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 type of data type conversion happens when the compiler encounters the following code?

884


What is the difference between an implicit conversion and an explicit conversion?

931


Can a constructor be static in c#?

970


What is generic in c#?

825


How big is a float?

871


What is private void in c#?

867


Between windows authentication and sql server authentication, which one is trusted and which one is untrusted?

931


What is the difference between returning iqueryable vs ienumerable?

917


What is the default value of string in c#?

968


How to declares a two-dimensional array in C#?

994


What kind of the information stored inside the assembly?

959


What is a hash table c#?

837


Can I define my own exceptions?

843


What are some examples of desktop applications?

884


what is generics? can u explain 5 to 6 examples on generics that covers class,method,structure,list,delegates?

1845