标签:
最近看了c#的数组,比c++的数组更加直接,.net也提供了很多直接直接操纵数组的方法,非常方便,所以就想做个总结。//注意 交错数组要求为内部的每个数组都创建实例,在这个例子中,我们使用new来实例化交错数组内部的元素,如果遗失这个实例化部分就会编译出错。
4.4.数组的使用 可以用方括号的方法建立索引。 5.5..NET对数组提供的API
Name.Length;//这是一个只读属性,只是这个数组的大小。
Name.Rank;//只读属性,指示这个数组的维数
Name.GetLength(int);//返回给定维数的长度,如代码
bool[,,] cells= new bool[2,3,3];
cells.Getlength(0); //这个函数的返回值为2
system.Array是所有数组的抽象基类,提供了很多操纵数组的静态方法,所以,数组是对象。
数组的其他实例方法 :Max();Min();Average();Sum();
equals(object obj);//返回两个对象是否相等
clone();浅度拷贝
静态方法:Array.sort();//对数组进行排序
Array.BinarySearch();//二分搜索,必须先排序。
Array.Copy();//拷贝两个数组。
Array.Clear();//将每个元素设置为默认值。
Array.indexof();//Searches for the specified object and returns the index of the first occurrence within the entire one-dimensional
ArrayArray.LastIndexOf();//Searches for the specified object and returns the index of the last occurrence within the entire one-dimensional ArrayArray.Reverse();//Reverses the sequence of the elements in the entire one-dimensional
Array.Reverse();Reverses the sequence of the elements in a range of elements in the one-dimensional
Array.sort(Array,Icomparer)//版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/tabe123/article/details/47752485