• C#集合类型


    using System;
    using System.Collections;
    using System.Collections.Generic;
    
    namespace codeTest
    {
        class Program
        {
            static void Main(string[] args)
            {
                //C#集合类型
    
                //数组都继承于System.Array  长度固定
                //一维数据
                int[] numbers = new int[5];
                //二维数据
                int[,] numbers2 = new int[5,5];
                //数组的数据
                int[][] numbers3 = new int[5][];
    
                //初始化
                int[] intArray = new int[5] { 1, 2, 3, 4, 5 };
                int[] intArray1 = new int[] { 1, 2, 3, 4, 5 };
                int[] intArray2 = { 1, 2, 3, 4, 5 };
                string[,] strArray = new string[,] { { "A", "B" }, { "C", "D" } };
                string[][] strArray1 = new string[][] { new string[] { "A", "B" }, new string[] { "C", "D" } };
    
    
                //列表都继承于System.Collection
                ArrayList AL = new ArrayList();
                AL.Add(100);
                AL.Add("ccc");
                AL.Remove(100);
                Console.WriteLine(AL[0]);
    
                List<int> ListA = new List<int>();
                ListA.Add(100);
                ListA.AddRange(new int[] { 101, 102, 103 });
                ListA.Contains(100);
                ListA.Remove(100);
                ListA.Insert(1, 200);
                ListA.InsertRange(1, new int[] { 201, 202, 203 });
                ListA.IndexOf(100);
    
                //哈希表
                Hashtable ht = new Hashtable();
                ht.Add(1, "1");
                ht.Add("2", 2);
                //字典
                Dictionary<int, string> dic = new Dictionary<int, string>();
                dic.Add(1,"1");
    
                //根据Key值排序
                SortedList<int, int> a = new SortedList<int, int>();
    
                //stack queue
            }
        }
    
    
    
    
    }
  • 相关阅读:
    [POJ 1200]Crazy Search
    [来源不详]删数方案数
    noip搜索模拟题 骰子
    [SDOI2010]地精部落
    [HAOI2008]硬币购物
    BZOJ1009: [HNOI2008]GT考试
    BZOJ1830: [AHOI2008]Y型项链 & BZOJ1789: [Ahoi2008]Necklace Y型项链
    BZOJ1251: 序列终结者
    BZOJ3620: 似乎在梦中见过的样子
    BZOJ4477: [Jsoi2015]字符串树
  • 原文地址:https://www.cnblogs.com/lgxlsm/p/4751857.html
Copyright © 2020-2023  润新知