读书人

请教C#中数组的父类是Object么?大写的

发布时间: 2013-08-04 18:26:15 作者: rapoo

请问C#中数组的父类是Object么?大写的Array和数组有什么关系?
都说一切皆对象,可是数组却并非继承自Object,那么C#中的数组,到底算什么?

大写的Array可以理解成数组的别称么?类似于Object与object,Int32与int那种关系?
[解决办法]
不知您所谓的 数组却并非继承自Object 是从何而来~
Array is the abstract base type of all array types. You can use the properties, and other class members, that Array has. An example of this would be using the Length property to get the length of an array.

所以
int[] x = new int[3];
object o = x;

Array array = x;
都是正确的
[解决办法]
数组继承自抽象基类Array
使用括号语法的时候后台会自动派生一个新类并创建其实例
也可以通过Array.CreateInstance()函数来显示创建数组

[解决办法]

引用:
数组继承自抽象基类Array
使用括号语法的时候后台会自动派生一个新类并创建其实例
也可以通过Array.CreateInstance()函数来显示创建数组

++1正解
[解决办法]
Object 是一切的对象的基类吧

读书人网 >C#

热点推荐