Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheritance concept in C# [duplicate]

Possible Duplicate:
Does C# support multiple inheritance?

Does C# support multiple inheritance?

like image 610
kumarsram Avatar asked Dec 03 '22 04:12

kumarsram


2 Answers

C# does not support multiple inheritance. It does support multiple implementation of interfaces (so your class can uses as many interfaces as it likes, only one base class tho')

like image 131
Colin Mackay Avatar answered Dec 15 '22 23:12

Colin Mackay


In short No, multiple inheritance is not supported.

This is not a problem as inheritance shall always translate to a "is-a" relationship. Objects usually are only of one kind.

On the other side interfaces, that translate to a "behaves like" relationship can be implemented multiple times.

This is not a limitation but rather an advantage to avoid many strange issues like the Diamond Problem.

like image 33
jdehaan Avatar answered Dec 15 '22 23:12

jdehaan