Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C# support multiple inheritance?

A colleague and I are having a bit of an argument over multiple inheritance. I'm saying it's not supported and he's saying it is. So, I thought that I'd ask the brainy bunch on the net.

like image 632
Neil Knight Avatar asked Mar 16 '10 16:03

Neil Knight


People also ask

What is the do in C?

The do-while statement lets you repeat a statement or compound statement until a specified expression becomes false.

Does C have do-while?

The C do while statement creates a structured loop that executes as long as a specified condition is true at the end of each pass through the loop.

What does |= mean in C?

The ' |= ' symbol is the bitwise OR assignment operator.


2 Answers

Sorry, you cannot inherit from multiple classes. You may use interfaces or a combination of one class and interface(s), where interface(s) should follow the class name in the signature.

interface A { } interface B { } class Base { } class AnotherClass { } 

Possible ways to inherit:

class SomeClass : A, B { } // from multiple Interface(s) class SomeClass : Base, B { } // from one Class and Interface(s) 

This is not legal:

class SomeClass : Base, AnotherClass { } 
like image 197
Asad Avatar answered Sep 22 '22 05:09

Asad


Nope, use interfaces instead! ^.^

like image 40
Barrie Reader Avatar answered Sep 22 '22 05:09

Barrie Reader