+ 3

Why c# has only one base class for a child class ?

20th Mar 2019, 10:04 PM
assellalou
assellalou - avatar
6 Réponses
+ 3
Multiple inheritance makes code more complex and vulnerable for bugs. It is often used wrong and sometimes used right. So according to Codeproject.com quote: They don't have multiple inheritance because their designers had to choose between have it in and have all the problems it comes with, or get it out of the language putting away all those problems, and introduce a versatile and less problematic substitute like interfaces and interface inheritance. https://www.codeproject.com/Articles/10072/Simulated-Multiple-Inheritance-Pattern-for-C End quote; Used I base class and multiple interface. Note it is allowed to do hierachical inheritance
21st Mar 2019, 8:09 PM
sneeze
sneeze - avatar
+ 3
Search Diamond Problem that was caused due to multiple inheritance in c++, so c# developers decided to make the language not to allow a class to be inherited from more than one classes.
24th Mar 2019, 6:21 PM
AI Machine
AI Machine - avatar
0
Can you explain your question a bit more ? Do you have a code example ?
21st Mar 2019, 7:41 PM
sneeze
sneeze - avatar
0
Class x : baseclasshere { }
21st Mar 2019, 7:42 PM
assellalou
assellalou - avatar
0
What would you like it to be ?
21st Mar 2019, 7:44 PM
sneeze
sneeze - avatar
0
Like having multiple base class
21st Mar 2019, 7:44 PM
assellalou
assellalou - avatar