简体   繁体   中英

multiple inheritance in c#.net - abstract classes

One quick question.

I understand that multiple inheritance is not supported in c#.net. But you can still achieve the functionality by implementing multiple interfaces. Now my question is Can a child class inherit from two or more classes as long as they are abstract?

In short, no. Multiple interface inheritance implementation is possible, but not multiple class inheritance (abstract or not).

You can't inherit from multiple classes, period. No matter if abstract or not. Read about extension methods, that may help you a bit: if your classes implement an interface, you can attach common functionality to them without inheritance and copy-paste.

No you can only inherit from one class whether it is abstract or concrete.

Here is link to a question that has quite a detailed discussion of abstract vs base classes

Interface vs Base class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM