.NET中多重继承的疑问 [英] Doubts in Multiple inheritance in .net

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

问题描述

我们知道所有类都是从.net中的对象类继承的.假设我们创建一个名为ClassA的类.然后,我们创建另一个名为ClassB的类,该类是从ClassA继承的.这不是多重继承,因为ClassB从Object类和ClassA继承了吗?这是否违反了C#.net不支持多重继承的规则?

We know that all the classes are inherited from the object class in .net. Say we create a class named ClassA. Then we create another class named ClassB that is inherited from ClassA. Isn't this multiple inheritance, because ClassB inherited from both Object class and ClassA? Doesn't this break the rule that C#.net doesn't support multiple inheritance?

推荐答案

不,您不会违反规则.由于ClassA是一个对象,所以并不意味着您要从2个不同的类继承.您从ClassA继承而来,因此继承了继承链"的所有特征.
您不是从2种不同的类型继承,因为ClassA是一个对象.

No, you do not break the rule. Since ClassA is an object, it does not mean that you're inheriting from 2 different classes. You're inheriting from ClassA, and thereby taking all the characteristics from the 'inheritance chain' with it.
You're not inheriting from 2 different types, since ClassA is an object.

这篇关于.NET中多重继承的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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