如果C#有多重继承? [英] Should C# have multiple inheritance?

查看:93
本文介绍了如果C#有多重继承?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所遇到的许多论据反对在C#中包含多重继承,其中一些包括(哲学论点除外):

I have come across numerous arguments against the inclusion of multiple inheritance in C#, some of which include (philosophical arguments aside):


  • 多重继承是太复杂,往往模棱两可

  • 这是不必要的,因为接口提供了类似的东西

  • 成分是很好的替代品,其中的接口都不合适

我来自一个C ++背景,错过电源和多重继承的优雅。虽然它不适合所有的软件设计在有些情况下是很难否认它已经结束了接口,组成和类似的面向对象的技术工具。

I come from a C++ background and miss the power and elegance of multiple inheritance. Although it is not suited to all software designs there are situations where it is difficult to deny it's utility over interfaces, composition and similar OO techniques.

时的多重继承的排斥说,开发商不够聪明明智地使用它们,没有能力解决复杂问题时,他们产生的?

Is the exclusion of multiple inheritance saying that developers are not smart enough to use them wisely and are incapable of addressing the complexities when they arise?

我个人欢迎引入多重继承到C#(也许Ç##)。

I personally would welcome the introduction of multiple inheritance into C# (perhaps C##).


附录:我很想从谁来自单个(或程序后台)与多重继承背景的反应就知道了。我常常发现,谁与多重继承没有经验的开发人员往往会默认为多重继承的是,没有必要只是因为他们没有与范式的经验参数。

Addendum: I would be interested to know from the responses who comes from a single (or procedural background) versus a multiple inheritance background. I have often found that developers who have no experience with multiple inheritance will often default to the multiple-inheritance-is-unnecessary argument simply because they do not have any experience with the paradigm.

推荐答案

我从来没有错过一次,不是永远。是的,它[MI]变得复杂,是的,接口确实在很多方面类似的工作 - 但这还不是最大的一点:在一般意义上,它根本不需要的大部分时间。即使是单继承过度使用在许多情况下。

I've never missed it once, not ever. Yes, it [MI] gets complicated, and yes, interfaces do a similar job in many ways - but that isn't the biggest point: in the general sense, it simply isn't needed most of the time. Even single inheritance is overused in many cases.

这篇关于如果C#有多重继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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