|
Arraylist是一个实现内存动态分配的范型数组,目前实现了14个方法,各方法的功能可参考.NET Framework库里的ArrayList,添加引用后再
using MyClassLibrary;
就ok了
测试:
System.Collections.ArrayList Al1 = new ArrayList(8);
MyArraylist.Arraylist Al3 = new MyArraylist.Arraylist(3);
MyArraylist.Arraylist Al2 = new MyArraylist.Arraylist();
AppMain[] Am = new AppMain[3];
Al3.Add(Am);
Al3.Add(null);
Al2.Add(Am);
//Al2.Add(Am);
Al1.Add(null);
//int i=Al1.Capacity;
//Console.WriteLine(i.ToString());
bool b=Al3.Contains(null);
Console.WriteLine(b.ToString());
b=Al2.Contains(null);
Console.WriteLine(b.ToString());
//Al2.Capacity = 5;
Al2.Add(Am);
//Al2.Insert(3,Am);
//Al2.Insert(4,Am);
int a=Al3.Count;
Console.WriteLine(a.ToString());
a=Al2.LastIndexOf(Am,1);
Console.WriteLine(a.ToString());
a=Al2.LastIndexOf(Am);
Console.WriteLine(a.ToString());
a=Al2.LastIndexOf(Am,1,2);
Console.WriteLine(a.ToString());
Al2.TrimToSize();
b=Al2.Contains(null);
Console.WriteLine(b.ToString());
//Al2.Add(Am);
Console.ReadLine();
return 0;
输出如下:
True
False
2
1
1
-1
False |
|