为什么Array.Sort()和Array.IndexOf()方法是静态的? [英] Why are Array.Sort() and Array.IndexOf() methods static?

查看:201
本文介绍了为什么Array.Sort()和Array.IndexOf()方法是静态的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

始终感兴趣的是为什么 Array.Sort() Array.IndexOf()方法制作的静态和类似的 ArrayList.Sort() ArrayList.IndexOf()设计为成员方法。感谢您的任何想法。

Always was interested why are Array.Sort() and Array.IndexOf() methods made static and similar ArrayList.Sort() and ArrayList.IndexOf() are designed as member methods. Thank you for any ideas.

推荐答案

在我看来,Array类基本上是一个类表示固定大小的数组, []在程序中(你可以画出类似int的类似于它的类(结构)表示为System.Int32)。

In my view Array class is basically a class representation of the fixed size arrays that we declare using [] in program (you can draw the analogy like int has it's class (structure) representation as System.Int32).

也是Array类不包含实际的数组数据在任何实例变量中,但它只提供静态效用函数,可以用来在声明的固定大小的数组中进行排序和搜索。

Also Array class does not contain the actually array data in any instance variables but it provides just static utility functions which can be utilized to do sorting and searching in the declared fixed size arrays.

另一方面,ArrayList是一个集合类,它提供动态大小数组实现,它有自己的数据结构来包含数据。因此,所述方法是实例方法,因此它们可以处理特定实例的数据。

On the other hand, ArrayList is a collection class, which provides dynamic size array implementation and it has it's own data-structure to contain the data. Therefore the said methods are instance methods, so that they can work on the that particular instance's data.

这篇关于为什么Array.Sort()和Array.IndexOf()方法是静态的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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