Introduction
Can you inherit from multiple classes in C#? Simply put, this cannot be done. However, there are ways around it. From a design perspective, you must ask yourself, Will a Class fully represent an object? Meaning that if we have a base class with abstract methods designed for a particular application and we know that the inheriting object will only need the methods defined in that class. We now have a valid design pattern here.
The Vehicle Car Object
Let's say we have an abstract class called "Vehicle" and another class called "ConstructionVehicle". The vehicle class has methods such as Accelerate(), Stop(), and the "ConstructionVehicle" class has methods such as ExecuteDump() and TurnOnBackUpSound(). If we were only going to build a Car object and know we would only use those methods from the "Automobile" class, this would be fine.
The DumpTruck Object
Now we want to create another object called "DumpTruck". We could inherit from the Automobile class, but that class does not have the methods that we need called ExecuteDump() and TurnOnBackUpSound(). If we were using a language such as C++, we could easily inherit from both classes using multiple inheritance. However, seeing C# is our language of choice, multiple inheritance is not an option. You may only inherit from one Base Class.
From Abstract Classes to Interfaces
From a design perspective, we must choose a different design. C# supports what is called "Multiple Implementation", which is to say a class can implement more than one interface. Our design now changes the "Vehicle" class and the "ConstructionVehicle" class into interfaces. Below we have defined the two interfaces with their very simplistic methods. i.e.
interface IConstructionVehicle
{
void ExecuteDump();
void TurnOnBackUpSound();
}
interface IVehicle
{
void Accelerate();
void Stop();
void TurnOnBackUpSound();
}
If we built a class that is inherited from these two interfaces, we would be able to do so spanning multiple inherited interfaces. Design problem solved!
Or is it?
Explicit Interface Implementation
If you look at both interfaces defined above, you'll notice that they share a common method of the same name, "TurnOnBackUpSound()". Problem? No, in fact, C# supports what is known as "Explicit Interface Implementation", which allows the programmer to specify which member of which interface they want to use. Putting the Interface name in front of the member name allows this to happen, as shown below.
public class DumpTruck : IEngine, IBody
{
void IEngine.Test()
{
Console.WriteLine("This is the Engine TEst");
}
void IBody.Test()
{
Console.WriteLine("This is the Body TEst");
}
}
Implementation Hiding
Another benefit to this technique is something called "Implementation Hiding". Implementation Hiding allows the methods from the implemented interface to be hidden from the derived class unless the developer explicitly calls the interface. This technique obviously reduces the clutter for a developer.

Joe WilsonPosted Dec 28, 2015, 10:55 AM
Well, it was great.
Nitin PaiPosted Jun 12, 2012, 2:38 AM
Multiple inheritance is where you can inherit behaviors from multiple classes. If I need multiple classes that needs to inherit behavior as per this example, I need to have implementation in each class. So behavior is not consistent across the classes as each class implements its own behavior. Solution to this problem could be, interface IEngine{} interface IBody{} class DumpTruck { void DumpTruck(IEngine, IBody){} } I believe IEngine and IBody behaviour remains consistent as long as same implementation classes are injected.
Beata PszczulskaeditedPosted May 2, 2012, 11:11 AMEdited May 2, 2012, 11:13 AM
Quite good article,Here I also have found good explanation of inheritance in .NET http://www.psworld.pl/Programming/Inheritance
Chetnaa DesaiPosted May 25, 2011, 5:04 AM
Poor.Not Clear.
SYED SUFIYANPosted Mar 8, 2011, 2:57 AM
i have class a { } class b:a { } class c:a { } can this be done...please reply soon thanks in advance...interview question
Oz AmaroPosted Sep 14, 2010, 8:12 PM
I think the article did exactly what it was suppossed to do, educate those that do NOT know enough about the subject and need help. Thank you so much, it did help. To the complainers: Stop being so errogant. Just because you see no value does not mean no value exists. You will never fly high with the eagles if you continue to behave like crow.
madhavarao suryaneniPosted Mar 26, 2010, 3:00 PM
how to achieve multiple inhertance,which method will execiute first and how ? by observing this code and send clear explanation without creating reference variable to the interfaces in c#.net 1. Interface Inter1 { void Test(); } 2.Interface Inter2 { void Test(); }
Kenneth TruyersPosted Feb 19, 2010, 5:09 PM
I think your explanation is very good, but the example is not correct. In this case you should just inherit ConstructionVehicle from Vehicle and make an inheritance hierarchy. A better example would be a class like a button. It can be pushed, or it can be dragged, so it would implement the interfaces IPushable and IDraggable. Other items (such as a Label), can only be dragged and would only implement IDraggable. Good explanation though With kind regards, Kenneth Truyers Host Ahead
JoePosted Nov 17, 2009, 10:06 AM
It is disconcerting that so many people had negative responses to this article. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p> The article was concise, to the point and covered at least a couple design issues (which is plenty for any article). Those who desire a thesis should spend their time searching for one, not insulting “quick summary” authors. As to “date of the article”, who cares? As to the obvious bash about professional programmers. I am one who wrote a flight simulator with shading before any were commercially available and a logistics algorithm attempted by 17 others before me (includes 6 PhD’s) that saves our nation an estimated 1.2 million per hour. <o:p> </o:p> I think this was great and thank you very much sir!
Dulantha FernandoPosted Aug 4, 2009, 6:29 PM
So what if I want to use the method definitions as well - not just the method signatures?
John RobertsonPosted Jun 26, 2009, 12:00 AM
This article is from 2001 when C# was a "newer" language. Posting in 2007-2009 saying your not impressed by this article makes me sad to program in C#. Because you cannot read a date, and just learned "Hello World" in VB doesn't mean you should search the web at night looking for foundation articles from 2001 and cry on them. Good thing none of you will ever program professionally... At least that is a relief.
Phan Thanh HuyPosted Jan 18, 2009, 12:41 AM
Not new anything
Jonathan LeonardPosted Nov 6, 2008, 6:07 PM
Suppose you also have ISportUtilityVehicle and IRover whose 'Accelerate' methods are no different than that of the base class. Then, the best you can do is put the common functionality in a static method and call it from all three implementations of 'Accelerate' (with one line wrappers). Isn't this the real PITA about single inheritance languages? I would be interested to see you actually address this elephant in the room.
Hari PaudelPosted Oct 17, 2008, 3:24 PM
why multiple inheritance is not good in programming?
Sujit KumarPosted Feb 27, 2008, 1:17 AM
interface is a vast topic.this car and vehicle is not sufficient. these article should not be posted like this.
surendra sambanaPosted Aug 23, 2007, 8:28 AM
Not at all impressive