zoukankan      html  css  js  c++  java
  • .NET中的集合-ArrayList1

    集合命名空间:

      using.System.Collections;(非泛型集合)

      using.System.Collections.Genneric(泛型集合)

    常用的集合

      1.“类似数组”集合:ArrayList、List<T>

      2.“键值对”集合(“哈希表”集合):Hashitable、Dictionry<K,V>

      3."堆栈"集合:Stack、Stack<T>(LIFO) Last InFirst Out

      4."队列"集合:Queue、Queue<T>(FIFO) First In First Out

       主要用的集合蓝色的集合。

    ArrayList中的count和capcity  一个是元素的个数,一个数容量,当存进一个元素的时候 count=1 容量为4,存第二个的时候count=2 capacity=4

    存入第5个的时候count=5 capacity=8,是因为capacity初始容量为4,当容量达到4的时候翻倍增长。

    数组循环遍历用的是length 而集合时count加上索引器

      向指定位置插入一个元素

        //添加元素

        arrlist.Insert(0,“皇上”);

        //添加元素-

        arrlist.addrange();方法 参数为ICollection接口。也就是说此参数可以传递集成ICollection接口的子类,它的子类有很多,基本上都是集合和数组

        arrlist.addrange(new int []{1,2,4,5,87,93,5});

        //删除元素

        arrlist.Removeat(0);

        arrlist.RemoveatRange();

        //清空集合

        arrlist.clear();

        

      

     

        

  • 相关阅读:
    [转]window.open居中
    WebService实例一
    开发步骤
    ubuntu命令
    ubuntu如何添加软件源
    WebService学习笔记
    android.view.WindowManager$BadTokenException: Unable to add window token null is not for an application
    Dialog的使用
    区分Activity的四种加载模式
    在android 中导入项目后 包出现错误
  • 原文地址:https://www.cnblogs.com/xiaowie/p/9463568.html
Copyright © 2011-2022 走看看