打印本文 打印本文 关闭窗口 关闭窗口
ArrayList-asp.net入门笔记(五)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2783  更新时间:2009/4/23 10:40:04  文章录入:mintao  责任编辑:mintao
aList.Add("e");

aList.Remove("a");

结果为b c d e

2. public virtual void RemoveAt(int index);

移除 ArrayList 的指定索引处的元素

aList.Add("a");

aList.Add("b");

aList.Add("c");

aList.Add("d");

aList.Add("e");

aList.RemoveAt(0);

结果为b c d e

 

3.  public virtual void RemoveRange(int index,int count);

ArrayList 中移除一定范围的元素。

Index表示索引,count表示从索引处开始的数目

aList.Add("a");

aList.Add("b");

aList.Add("c");

aList.Add("d");

aList.Add("e");

aList.RemoveRange(1,3);

结果为a e

4.  public virtual void Clear();

从 ArrayList 中移除所有元素。

 

五.排序

a)       public virtual void Sort();

对 ArrayList 或它的一部分中的元素进行排序。

ArrayList aList = new ArrayList();

aList.Add("e");

aList.Add("a");

aList.Add("b");

aList.Add("c");

aList.Add("d");

DropDownList1.DataSource = aList;  // DropDownList DropDownList1;

DropDownList1.DataBind();

结果为e a b c d

ArrayList aList = new ArrayList();

aList.Add("a");

aList.Add("b");

aList.Add("c");

aList.Add("d");

aList.Add("e");

aList.Sort();  //排序

DropDownList1.DataSource = aList;  // DropDownList DropDownList1;

DropDownList1.DataBind();

结果为a b c d e

b)       public virtual void Reverse();

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口