Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple inheritance in C#

As I am working as a C# developer, I know that we can implement multiple inheritance by use of Interface.

Can anybody please provide me link OR code for how to achieve multiple inheritance with C#.

I want code for how to achieve multiple inheritance in C# with the use of Interface.

Thanks in advance.

like image 552
nunu Avatar asked Aug 13 '10 05:08

nunu


1 Answers

It's not strictly multiple inheritance - but your C# class can implement multiple interfaces, that's right:

public class MyClass : BaseClass, IInterface1, IInterface2, IInterface3
{
   // implement methods and properties for IInterface1
   ..

   // implement methods and properties for IInterface2
   ..

   // implement methods and properties for IInterface3
   ..
}

You need to provide implementations for all methods (and properties) defined in all of the interfaces you're planning to implement.

I'm not quite clear on what you are looking for from your question.... can you clarify a bit?? What are you trying to do? Where are you running into trouble??

like image 169
marc_s Avatar answered Sep 30 '22 18:09

marc_s