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.

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / varish

Class Base
{
Base(int i)
{
}
}
class child
{
child(int i):base(i)
{
}
}

Is This Answer Correct ?    5 Yes 1 No

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

Answer / ram

Class Base
{
Base(int i)
{
}
}
class child
{
child(int i):Base(i)
{
}
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

2 Answers   Siebel Systems,


Can we inherit private class in c#?

0 Answers  


Which is faster hashtable or dictionary?

0 Answers  


what are nullable types in c#

0 Answers   Cognizant,


Why data types are important?

0 Answers  


What is difference between singleordefault and firstordefault?

0 Answers  


What is property c#?

0 Answers  


What is check/uncheck?

0 Answers  


How can I check the type of an object at runtime?

0 Answers  


How can I access the registry from c# code?

0 Answers  


What is a system lock?

1 Answers   AZTEC, Wipro,


I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?

0 Answers  


Categories