Possible Duplicate:
Multiple Inheritance in C#
I have two classes Class A and Class B. These two classes cannot inherit each other. I am creating new class called Class C. Now, I want to implement the methods in class A and class B by inheriting. I am aware that multiple inheritance is not possible in C# but is there any other way to do this?
Multitiple inheritance is not possible in C#, however it can be simulated using interfaces, see Simulated Multiple Inheritance Pattern for C#.
The basic idea is to define an interface for the members on class
Bthat you wish to access (call itIB), and then haveCinherit fromAand implementIBby internally storing an instance ofB, for example:There are also a couple of other alternaitve patterns explained on that page.