当我们创建类 Product 时
class Product
{
}
我从不同的博客和书籍中了解到,Object
类是每个类(包括用户定义类)的父类(super class)/基类/父类。
这是怎么发生的?
我假设它是由 .NET Framework 处理的?如果是这样,那么我很想知道这是怎么发生的。
最佳答案
根据 MSDN :
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.
为什么你在代码中看不到这一点:
Languages typically do not require a class to declare inheritance from Object because the inheritance is implicit.
简而言之,.Net 类型系统会隐含地执行此操作。
关于c# - .NET 类默认继承对象类。如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28500287/