Multiple Inheritance, like you have mentioned, isnt supported. To achive
what you wish, the more advanced mechanism to assume is that of delegation.
Out of the three classes you wish to inherit functionality, choose the best
abstraction for the root. Try using the is-a test to make sure you get the
most appropriate class. On this class, realize the two other interfaces
(roles) by implementing them on the class:
public class A : IRoleB, IRoleC
{
private IRoleB _iRoleB;
private IRoleC _iRoleC;
public A(IRoleB roleBImplementation, IRoleC roleCImplementation)
{
_iRoleB = roleBImplementation;
_iRoleC = roleCImplementation;
}
// IRoleB methods
....
// IRoleC methods
...
}
In many cases, multiple inheritance of three classes (or even two) can
typically be broken down into the design above, which is much more flexible,
and open and closed.
HTH
Nick.
"ligth_wt" <an*******@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
Hi,
I think the derived class in C# can inherit from only one class. So, if I
need multiple inheritances, I will need to have interfaces. However,
interfaces doesn't have the implementation of methods. Suppose, if I want
to have a derived class inherit the actual methods from 3 different base
classes, how can I do that?
Thanks.