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

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

问题描述

总是很感​​兴趣,为什么的Array.Sort() Array.IndexOf()方法制成的静和类似 ArrayList.Sort()和< A HREF =htt​​p://msdn.microsoft.com/en-us/library/system.collections.arraylist.indexof.aspx相对=nofollow> 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类基本上是固定大小的数组,我们宣布在程序中使用[]的一类重presentation(你可以借鉴的比喻如int有它的类(结构)再presentation为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).

另外阵列类不包含在任何实例变量的实际阵列数据,但它提供了可以用来做排序和搜索中所声明的固定大小的数组只是静态实用功能。

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天全站免登陆