zoukankan      html  css  js  c++  java
  • 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
            }
        }
    
    
    
    
    }
  • 相关阅读:
    Android之动态图片
    Java之简单图形面积计算
    Java之姐妹素数
    Java之经典Student问题2
    数据库事务四大特性
    TCP/IP分层
    海量数据问题处理办法
    36个常见java面试题
    【19】【滑动窗口】【栽跟头】最长不重复子字符串
    一些面试题
  • 原文地址:https://www.cnblogs.com/lgxlsm/p/4751857.html
Copyright © 2011-2022 走看看