.NET类默认情况下继承对象类。怎么样? [英] .NET class inherits object class by default. How?
问题描述
当我们创建类产品
class Product
{
}
从不同的博客和书籍中学到的 Object
类是每个类的超级/基类/父类,包括用户定义的类。
What I have learned from different blogs and books that Object
class is the super/base/parent class of every class including user-defined classes.
这是怎么发生的?
我认为.NET Framework会注意它吗?如果是这种情况,那么我很好奇这是怎么发生的。
I assume it is taken care by .NET Framework? If its the case then I am curious to know how does this happens.
推荐答案
按照MSDN :
支持.NET Framework类层次结构中的所有类,并为派生类提供低层服务。这是.NET Framework中所有类的最终基类。这是类型层次结构的根。
Supports all classes in the .NET Framework class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all classes in the .NET Framework; it is the root of the type hierarchy.
为什么不在代码中看到这个?
And why do you not 'see' this in the code:
由于继承是隐式的,语言通常不需要类来声明从Object继承。
Languages typically do not require a class to declare inheritance from Object because the inheritance is implicit.
因此,简而言之,.Net类型系统会隐式执行此操作。
So in short the .Net type system does this implicit.
这篇关于.NET类默认情况下继承对象类。怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!