zoukankan      html  css  js  c++  java
  • 第二课时《数组集合》

            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:从方法跳回到查询里
  • 相关阅读:
    Unix环境编程之文件IO
    navicat 导出查询结果
    Java 原子类 java.util.concurrent.atomic
    AtomicBoolean介绍
    ExecutorService常用方法和newFixedThreadPool创建固定大小的线程池
    ExecutorService与Executors例子的简单剖析
    tomcat6版本虚拟目录详细配置
    生产者与消费者模型案例
    如何设计一个LRU Cache
    在MVC模式下通过Jqgrid表格操作MongoDB数据
  • 原文地址:https://www.cnblogs.com/zhangyuG/p/11140768.html
Copyright © 2011-2022 走看看