System.Collections.ArrayList类是一个特殊的数组。通过添加和删除元素,就可以动态改变数组的长度。
一.优点
1。支持自动改变大小的功能
2。可以灵活的插入元素
3。可以灵活的删除元素
二.局限性
跟一般的数组比起来,速度上差些
三.添加元素
1. public virtual int Add(object value);
将对象添加到 ArrayList 的结尾处
ArrayList aList = new ArrayList();
aList.Add("a");
aList.Add("b");
aList.Add("c");
aList.Add("d");
aList.Add("e");
内容为a b c d e
2. public virtual void Insert(int index,object value);
将元素插入 ArrayList 的指定索引处
aList.Insert(0,"aa");
结果为aa a b c d e
3. public virtual void InsertRange(int index,ICollection c);
将集合中的某个元素插入 ArrayList 的指定索引处
ArrayList list2 = new ArrayList();
list2.Add("tt");
list2.Add("ttt");
aList.InsertRange(2,list2);
结果为a b tt ttt c d e
四.删除
a) public virtual void Remove(object obj);
从 ArrayList 中移除特定对象的第一个匹配项,注意是第一个
[1] [2] [3] [4] 下一页
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18