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...

What are the keywords used to pass parameters to
the base class and how do I invoke other constructors.

Answer Posted / radhika

using base keyword we can pass parameters to the baseclass.
When an instance of the DerivedClass is created.The default
constructor in BaseClass is first invoked followed by the
DerivedClass . However, you
can choose which constructor you want to invoke in
BaseClass by using the base keyword in the
default constructor in DerivedClass , like this:

public class BaseClass
{
//---default constructor---
public BaseClass()
{
Console.WriteLine(“Default constructor in BaseClass”);
}
//---parameterized constructor---
public BaseClass(int x)
{
Console.WriteLine(“Parameterized Constructor in BaseClass”);
}
}

public class DerivedClass : BaseClass
{
//---default constructor---
public DerivedClass(): base(4)
{
Console.WriteLine(“Constructor in DerivedClass”);
}
}

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the Different types of configuration files in .net?

997


Explain the difference between boxing and unboxing.

1015


Explain concurrency with aop?

982


What is IL / CIL / MSIL?

1092


Define c# i/o classes?

924


How do I run a cshtml file?

911


You have got 1 million parking slots. At a time a parking slot can be free or not. To get next slot easily which data structure to implement?

1077


What is difference between class and abstract class in c#?

920


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

891


1. Describe page life cycle?

2109


What is the importance of closing an ado.net application?

899


What is type safe code?

872


Explain the difference between user control and custom control. Also, explain their use.

1059


Can a string be null c#?

890


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

1112