System.Object的是基类 [英] System.Object being the base class

查看:111
本文介绍了System.Object的是基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这问题可能是平时为多,我尝试过了一个小时,了解的东西,但没有得到适当的解释。

This question may be usual for many, i tried for an hour to understand the things but getting no proper explanation.

MSDN说, System.Object的是最终的基类.NET Framework中的所有类的;它是类型层次的根。

在C#中不允许多重继承,我怎么能继承,说A级到B级。 ?因为所有类,已经从System.Object继承权?
在这里,我说的是正常的继承。

When C# doesn't allow multiple inheritance, how can I inherit, say a Class A to Class B. ? Because all classes, already inherits from System.Object right? Here I am talking about the normal inheritance.

Class A { --- }
Class B : A { --- }

请,清除我的疑虑。
谢谢

Please, clear my doubts. Thank you.

更新:

再次我的疑问左右,所有从System.Object继承类,那么这将使具有A级B级以及System.Object的。从我上面的例子

Again, My doubt is about, All classes inheriting from System.Object, then that would make Class B having Class A as well as System.Object. From my above example

推荐答案

正确,C#只允许单一的传承。 System.Object类是由你的A级。所以,B类继承隐is-a的A,这是 - 一个System.Object。这是由编译器,所以你不需要直接说照顾了 A类:System.Object的(虽然你可以的,如果你想)

Correct, C# only allows single inheritence. The System.Object class is inherited implicitly by your Class A. So Class B is-a A, which is-a System.Object. This is taken care of by the compiler so you don't need to explicitly say that Class A : System.Object (though you can if you want).

这篇关于System.Object的是基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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