还原.NET Framework类库的Arraylist
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;
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 为社区提供新闻线索,得奖励 149 思明论坛!
下次努力哦!……我用的是2005的。不知道。。我现在有些东西搞不了 :( :(看不懂噢``
页:
[1]