| 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] 下一页 |