您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp.net >> 正文

ArrayList:ASP.NET入门笔记(五)

作者:佚名    信息学院来源:整理    点击数:    更新时间:2008-1-30 我要参与讨论

 

  ArrayList

  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 的指定索引处

ArrayList aList = new ArrayList();

aList.Add("a");

aList.Add("b");

aList.Add("c");

aList.Add("d");

aList.Add("e");

aList.Insert(0,"aa");

结果为aa a b  c d e

3.  public virtual void InsertRange(int index,ICollection c);

   将集合中的某个元素插入 ArrayList 的指定索引处

  ArrayList aList = new ArrayList();

aList.Add("a");

aList.Add("b");

aList.Add("c");

aList.Add("d");

aList.Add("e");

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 中移除特定对象的第一个匹配项,注意是第一个

ArrayList aList = new ArrayList();

aList.Add("a");

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

在google里搜索更多ArrayList:ASP.NET入门笔记(五)

Google
Web www.51ec.org
  • 上一篇信息学院:

  • 下一篇信息学院:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    我来说两句 对此文章发表了评论
      昵 称: *必填    ·注册用户·
      评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
    评 论
    内 容

     
    评论列表 (最新 评论仅限网友观点!)

    供求信息




    | 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明