• ArrayList的使用


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Collections;

    namespace arraylist集合
    {
      class Program
      {
        static void Main(string[] args)
      {
      //创建了一个集合对象
      ArrayList list = new System.Collections.ArrayList();
      //集合:很多数据的集合
      //数组:长度不可变、类型单一
      //集合的好处:长度可以任意改变,类型随便
      list.Add(1);
      list.Add(3.14);
      list.Add(true);
      list.Add("张三");
      list.Add('男');
      list.Add(5000m);
      //添加集合元素
      list.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
      //list.AddRange(list);

      //list.Clear();清空所有元素
      //list.Remove(true);删一个元素
      //list.RemoveAt(0);根据下标索引删除元素
      //list.RemoveRange(0,3);根据下表移出一定范围的元素
      list.Sort();//升序排序
      list.Reverse();//反转
      list.Insert(1,"插入的");//插入单个元素
      list.InsertRange(0, new string[] { "张三" ,"李四"});
      bool b = list.Contains(1);//判断包含

      for (int i = 0; i < list.Count; i++)
      {

        Console.WriteLine(list[i]);
      }
      Console.ReadKey();
      }
     }
      public class Person
      {
        public void SayHello()
        {
        Console.WriteLine("我是人类");
        }
      }
    }

  • 相关阅读:
    A JavaScript Tree component which implements the J.Q.Walker II layout algorithm
    决策树Ecotree(转)
    Elasticsearch中关于transform的一个问题分析
    转发sqlserver http://www.cnblogs.com/jiazengtao/archive/2013/05/29/3102803.html
    时间GMT
    C#去掉json字符串中的换行符
    收藏的好的Jquery+css3
    存储过程中日期的转换
    关于头文件
    关于头文件
  • 原文地址:https://www.cnblogs.com/lz-huihui/p/11300733.html
Copyright © 2020-2023  润新知