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

Which framework is best for desktop application?

929


If casting fails what type of exception is thrown?

816


Is array reference type in c#?

841


What is view state c#?

825


code for arranging given number in possible permutation ways ex:123,321,312,132,231,213.

2115


Which namespace is required to implement trace ?

915


What can you do as a .net developer?

880


What is the benefit of interface in c#?

889


Why constructor is used in c#?

849


List the two important objects of ado.net and also list the namespaces that are commonly used in ado.net to aid in connection to a database.

852


What is difference between array and arraylist in c#?

886


How does bitwise work?

851


Explain the different types of delegates used in c#.

886


What is the file extension for c#?

958


What is monitor in C#?

961