Why can't you do multiple inheritance in C #?

Possible duplicate:
Should C # include multiple inheritance?

Why doesn't C # support multiple inheritance?

public partial class Child: Parent1 { void MakeParent1Mad(); } public partial class Child: Parent2 { void MakeParent2Mad(); } 
+4
source share
1 answer

http://blogs.msdn.com/b/dachou/archive/2008/04/17/net-and-multiple-inheritance.aspx

  • .NET was designed to support multiple languages, but not all languages ​​can support multiple inheritance effectively. Or technically they could, but the added complexity in the semantics of the language of these languages ​​is more complicated (and less similar to their roots, like VB, and for backward compatibility reasons) and there is no compromise between the possibility of reusing code in the form of several inheritance
  • It would also make the cross-language compatibility library (CLS compliant) less reality than today, which is one of the most compelling features of .NET. There are over 50 languages ​​supported by .NET in over 70 introductions today
  • The most visible factor is linguistic semantics of complexity. In C ++, we needed to add explicit language features in order to address the ambiguity (for example, the classic diamond problem) caused by multiple inheritance, such as the “virtual” keyword to support virtual inheritance, to help the compiler resolve inheritance paths (and correctly use him)
  • As we know, the code is written in 20% of cases, but read 80% of the time. Thus, advocates on the side of simplicity prefer not to add language features for the sake of keeping semantics simple. Comparing C # code is much easier to read than C ++ code, and perhaps easier to write
+4
source

All Articles