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


How do you implement multiple inheritance in .NET?

Answers were Sorted based on User's Feedback



How do you implement multiple inheritance in .NET?..

Answer / vijay sharma

We can use interfaces to achieve multiple inheritance
in .NET

Is This Answer Correct ?    49 Yes 2 No

How do you implement multiple inheritance in .NET?..

Answer / vijay rana

with the help of interface we can achieve multiple
inheritense in csharp;

Is This Answer Correct ?    25 Yes 2 No

How do you implement multiple inheritance in .NET?..

Answer / mahesh kotekar

The actual answer is. We cannot provide multiple
inheritance in C#. Multiple inheritance means having a
common implementation from two base class derived in the
child class which is not possible. Using interface we just
provide the prototype which we can implement in the derived
classing which provides a mimic of multiple inheritance. If
am wrong please let me know.
Thanks And Regards
Mahesh Kotekar

Is This Answer Correct ?    13 Yes 3 No

How do you implement multiple inheritance in .NET?..

Answer / kamal

When we use the Multiple inheritance we use more than one
class. Lets one condition class A and class B are base
classes and class c is is multiple inherting it.And where
class c is inheriting a function .It may be possible that
this function with same name and same signature can present
in both class A and Class B . That time how the compiler
will know that which function it should take whether from
class A or class B.So Multiple inheritance show's an error.

Is This Answer Correct ?    7 Yes 3 No

How do you implement multiple inheritance in .NET?..

Answer / ashish

Dear All,

Please help me I am confused with concept of interface.

Every book and every post says that multiple inheritance is
achived by interface as a class implement more then 1
interfacet, but is it really a multiple inheriance ?

Inteface just provides prototype and not any
functionality , so even if class implements more then one
inteface class has to write its code to implement it and if
any other class is also implemnting interface that class
also has to write code to implemnt it , so how multiple
inheritance is achieved.

Is This Answer Correct ?    5 Yes 2 No

How do you implement multiple inheritance in .NET?..

Answer / adavesh

Ofcourse using interfaces !!!

Its not just implementing 2 or more than one interfaces.
Its more than that. Lemme explain with a sample example

public namespace AccountManagement
{
public interface ICalcInterestOnLoan
{
double GetInterestOnLoan(double
dloanAmount);
}

public interface ICalcInterestOnDeposit
{
double GetInterestOnDeposit(double
dPrincipleAmount);
}

class LoanManager: ICalcInterestOnLoan
{
double GetInterestOnLoan(double dloanAmount)
{
//NOTE: All logic for calculating loan
interest goes here
}
}

class PrincipleManager: ICalcInterestOnDeposit
{
double GetInterestOnDeposit(double
dPrincipleAmount)
{
//NOTE: All logic for calculating
deposit interest goes here
}
}

public class AccountManager:ICalcInterestOnLoan,
ICalcInterestOnDeposit
{
ICalcInterestOnLoan oLoanInterest = new
LoanManager();
ICalcInterestOnDeposit oDepositInterest = new
PrincipleManager();
double GetInterestOnLoan(double dloanAmount)
{
return oLoanInterest.GetInterestOnLoan
(dLoanAmount);
}

double GetInterestOnDeposit(double
dPrincipleAmount)
{
return
oDepositInterest.GetInterestOnDeposit(dPrincipleAmount);
}
}

}//namespace ends


Here PrincipleManager & LoanManager are internal classes.
So, external assemblies do not know those classes. The
class AccountManager indirectly inherits the
functionalities of two classes & hence multiple inheritance
is achieved

Kote... got it ?

Is This Answer Correct ?    6 Yes 3 No

How do you implement multiple inheritance in .NET?..

Answer / phaniram.h

by appling interface keyword to the base class we can
implement multiple inheritance in .NET

Is This Answer Correct ?    11 Yes 10 No

How do you implement multiple inheritance in .NET?..

Answer / cnu

Multiple inheritance means having more than 2 classes at
base level and only one class is derived from them.

In two cases only we can implement inheritance.

1.If we have maximum one class and minimum one interface at
base level.(its not possible in java).

2.If we have two or more interfaces at base level.

Is This Answer Correct ?    1 Yes 0 No

How do you implement multiple inheritance in .NET?..

Answer / pawan kumar tiwari

Inteface just provides prototype and not any
functionality , so even if class implements more then one
inteface class has to write its code to implement it and if
any other class is also implemnting interface that class
also has to write code to implemnt it , so how multiple
inheritance is achieved.

Is This Answer Correct ?    1 Yes 1 No

How do you implement multiple inheritance in .NET?..

Answer / ranjanatyagi

By using multiple Inheritence.

Is This Answer Correct ?    6 Yes 29 No

Post New Answer

More C Sharp Interview Questions

How encapsulation and abstraction defined/used in C#.NET.

8 Answers   Synechron,


what is the difference between int and Int32?

5 Answers   TCS,


Explain when should you call the garbage collector in .net?

0 Answers  


Any .net training centers available near hitech city , hyderabad?

2 Answers  


What is the difference between disposing of () and finalize() methods in c#?

0 Answers  


What is sqlcommand in c#?

0 Answers  


What does console readline do?

0 Answers  


Hai I am Shiva from TN, SSE.I have an query problem. My Table : Door Field : ID,DoorID,ZoneID,Date,Time,Status. Problem was : Status.We got two values, one is 00 (OUTTIME) , Another is 01(INTIME) Like this Status --------- 00 01 00 01 00 01 00 01 How to Set as Status 00 and 01 , of separate column , Status as Intime,Status as Outtime Like this ----------- InTime OutTime ---------- ----------- 01 00 01 00 01 00 01 00 01 00 01 00 Regards KS kumar

1 Answers  


Why singleton pattern is used in c#?

0 Answers  


what is Encapsulation?

7 Answers   IBM, Tech Mahindra,


What is the difference between a field and a property in c#?

0 Answers  


Hi to all..I have to create an intranet application on C#.NET windows Application so please please let can you people help me as iam new in .NET and if u have any samples or website address from where i can get sample please let know.

0 Answers   ABB, TCS,


Categories