C# array数组的用法范例:
type[] typename=new type[size];
如int[] a=new int[5];string[] str=new string[5];
C# ArrayList数组的用法范例:
ArrayList al = new ArrayList();
ArrayList和Array相互之间的转化
把ArrayList数组中的值拷贝到Array中去的实例用法
//int[] Idata=new int[al.Count];
//al.CopyTo(Idata);
//或是用下面的方法
//int[] Idata= (int[])al.ToArray(typeof(Int32));
//Person[] personArrayFromList = (Person[])personList.ToArray(typeof(Person));
把Array数组中的值拷贝到ArrayList中去的实例用法
int[] a ={ 222, 333, 555 };
ArrayList arrList = new ArrayList();
foreach (object obj in a)//或foreach (int obj in a)
{
arrList.Add(obj);
}
type[] typename=new type[size];
如int[] a=new int[5];string[] str=new string[5];
C# ArrayList数组的用法范例:
ArrayList al = new ArrayList();
ArrayList和Array相互之间的转化
把ArrayList数组中的值拷贝到Array中去的实例用法
//int[] Idata=new int[al.Count];
//al.CopyTo(Idata);
//或是用下面的方法
//int[] Idata= (int[])al.ToArray(typeof(Int32));
//Person[] personArrayFromList = (Person[])personList.ToArray(typeof(Person));
把Array数组中的值拷贝到ArrayList中去的实例用法
int[] a ={ 222, 333, 555 };
ArrayList arrList = new ArrayList();
foreach (object obj in a)//或foreach (int obj in a)
{
arrList.Add(obj);
}
本文介绍了C#中Array和ArrayList的基本用法,包括初始化、转换及如何将Array中的值拷贝到ArrayList中等关键操作。

1475

被折叠的 条评论
为什么被折叠?



