• 第二课时《数组集合》


            static void Main(string[] args)
            {
                Console.WriteLine("=====一维数组的基本使用1=====");
                int[] intArray = new int[3]; //定义数组长度为3
                intArray[1] = 123;//为数组传值,数组从0开始
                Console.WriteLine("intArray[1]:" + intArray[1]);//调取值得方法
                Console.WriteLine("=====一维数组的基本使用2=====");
                int[] intArray1 = new int[] { 123, 12, 11 };//直接赋值,不用定义长度
                Console.WriteLine("=====一维数组的基本使用3=====");
                int[] intArray2 = { 1, 2, 3, 4, 5, 6 };
                //通过遍历输出要获取到的值
                for (int i = 0; i < intArray2.Length; i = i + 2)
                {
                    Console.WriteLine(intArray2[i]);
                }

                Console.WriteLine("=====二维数组的基本使用=====");
                int[,] arr1 = new int[2, 3];//定义二维数组
                int[,] arr2 = new int[2, 3]{ { 123, 11, 22 }, { 123, 11, 12 } };
                int[,] arr3 = {
                    { 123,11,22},//坐标为0,/0,1/0,2
                    { 44,33,55} //坐标为/1,0/1,1/1,2
                };
                //输出 第二维 第二个元素
                Console.WriteLine(arr3[1, 1]);
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        Console.Write(arr3[i, j] + " ");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("=======不规则 数组的基本使用======");
                int[][] arrs1 = {
                    new int[] { 1,2},
                    new int[] { 1,2,3,4,5},
                    new int[] { 1,2,3,4,5,6,7,8,9}
                };
                Console.WriteLine(arrs1[2][4]);
                for (int i = 0; i < arrs1.Length; i++)
                {
                    for (int j = 0; j < arrs1[i].Length; j++)
                    {
                        Console.Write(arrs1[i][j] + " ");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("=======动态数组的基本使用======");
                ArrayList list = new ArrayList();
                list.Add(12);
                list.Add("AAC");
                list.Add(true);
                list.Add(2D);
                list.Add(2F);
                list.Add(DateTime.Now);
                list.Add(2.13);
                var aa = list[0];
                int bb = Convert.ToInt32(aa) + 1;
                foreach (var item in list)
                {
                    Console.WriteLine(item);
                }
     
    集合:用于存储类型不固定,长度可动态添加元素的
    1,BCL(Base Class Library)中集合类型分为泛型集合与非泛型集合
    2,非凡性集合的类和接口位于System.Collections命名空间
    3,泛型几个的类和接口位于System.Collections.Generic命名空间
     System.Collenction命名空间的类
     动态数组(ArrayList)
     哈维表(Hashtable)
     排序列表(SortedList)
     堆栈(Stack)
     队列(Queue)
     点阵列(BitArray)
    VS调试的按键:
    F5:跳到下一个断点
    F10:逐行查询语句
    F11:从查询中跳入到方法里
    Shift+F11:从方法跳回到查询里
    浏览器的调试键:
    F8:跳到下一个断点
    F10:逐行查询语句
    F11:从查询中跳入到方法里
    Shift+F11:从方法跳回到查询里
  • 相关阅读:
    文件File
    Vuex 模块化实现待办事项的状态管理
    浅谈jquery插件开发模式*****************************************************************************************
    git 详细的操作指南笔记
    Vue学习之路---No.5(分享心得,欢迎批评指正)
    Java 向Hbase表插入数据报(org.apache.hadoop.hbase.client.HTablePool$PooledHTable cannot be cast to org.apac)
    MongoDB -- 查询
    3 分钟学会调用 Apache Spark MLlib KMeans
    架构设计:负载均衡层设计方案(4)——LVS原理
    Linux内核:关于中断你须要知道的
  • 原文地址:https://www.cnblogs.com/zhangyuG/p/11140768.html
Copyright © 2020-2023  润新知