多重继承是不支持DOTNET。但是,多接口支持? [英] Multiple inheritance is not supported in dotnet. But multiple interface supports?

查看:157
本文介绍了多重继承是不支持DOTNET。但是,多接口支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  在C#中 多重继承

Possible Duplicate:
Multiple Inheritance in C#

多重继承是不支持DOTNET。但是,多接口支持。为什么这种行为的存在。 任何具体的原因?

Multiple inheritance is not supported in dotnet. But multiple interface supports. Why this kind of behaviour exists. Any specific reasons??

推荐答案

您可以模拟多使用继承接口。如果多重继承类被允许的,它会导致钻石问题的。照片为原因不支持多重继承,我建议你阅读为什么没有按'吨碳#支持多重继承?

You can simulate multiple inheritance using interfaces. If multiple inheritance with classes were allowed, it would lead to the Diamond problem.
For reasons multiple inheritance is not supported, I suggest you read Why doesn't C# support multiple inheritance?

不同的语言居然有   如何MI不同的期望   作品。例如,如何冲突   解决,是否重复基地   合并或冗余。之前,我们可以   在CLR实现MI,我们要做的   所有语言的调查,数字   出了共同的概念,并决定   如何PSS他们前$ P $的   与语言无关的方式。我们还   必须决定是否MI属于   华彩什么这将意味着   不希望这个概念语言   (presumably VB.NET,例如)。的   当然,这是我们在业务   作为一种公共语言运行库,但我们   还没有得到周围做它的MI   呢。

Different languages actually have different expectations for how MI works. For example, how conflicts are resolved and whether duplicate bases are merged or redundant. Before we can implement MI in the CLR, we have to do a survey of all the languages, figure out the common concepts, and decide how to express them in a language-neutral manner. We would also have to decide whether MI belongs in the CLS and what this would mean for languages that don't want this concept (presumably VB.NET, for example). Of course, that's the business we are in as a common language runtime, but we haven't got around to doing it for MI yet.

的名额,其中MI是真正的   适当的其实是相当小的。   在许多情况下,多个接口   继承可以完成这项工作   代替。在其他情况下,你可能会   能够使用封装和   代表团。如果我们要增加一个   稍有不同的结构,如   混入,将实际比较   厉害?

The number of places where MI is truly appropriate is actually quite small. In many cases, multiple interface inheritance can get the job done instead. In other cases, you may be able to use encapsulation and delegation. If we were to add a slightly different construct, like mixins, would that actually be more powerful?

多重实现继承   注入大量的复杂的进   实现。这种复杂性   影响铸造,布局,调度,   字段访问,序列化,身份   比较,可验证性,   反思,仿制药,而且可能   很多其他地方的。

Multiple implementation inheritance injects a lot of complexity into the implementation. This complexity impacts casting, layout, dispatch, field access, serialization, identity comparisons, verifiability, reflection, generics, and probably lots of other places.

这篇关于多重继承是不支持DOTNET。但是,多接口支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆