c# - .NET 类默认继承对象类。如何?

标签 c# .net object

当我们创建类 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/

相关文章:

Javascript:将对象值数组放入div

c# - 如何在 WPF 中获得有/无周末的选定月份的总天数?

c# - 使用 Entity Framework Code First 在 PostgreSQL 中存储图像

c# - SQL 搜索多个列的多个值列表

c++ - 等待 DownloadFileAsync 与 ManualResetEvent c++/cli

c# - 根据项目和子项目的文本查找 ListView 项目

java - 为什么输出字符串传递的不是对象

c# - 从 xmlDocument 中选择特定的 xml 节点,然后更改 xml 节点的属性

.net - 如何使用多个参数调用 RESTful WCF 服务方法?

java - 一个类有自己类型的字段可以吗