posts - 206,  comments - 26,  views - 17万
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
复制代码
    class Program
    {
        static void Main(string[] args)
        {
           // TestJiaoCuo();
            Console.ReadKey();
        }

        //交错数组.
        static void TestJiaoCuo()
        {
            //交错数组. 交错数组的本质是1个1维数组 只不过这个1维数组的元素又是数组,.
            int[][] arr = new int[3][];
            arr[0] = new int[3];
            arr[1] = new int[5];
            arr[2] = new int[4];
            Console.WriteLine(arr.Rank);//数组的维数 交错数组是1
            Console.WriteLine(arr.Length);//长度是3
            //遍历
            //foreach (int[] item in arr)
            //{
            //    foreach (int i in item)
            //    {
            //        Console.WriteLine(i);
            //    }
            //}

            for (int i = 0; i < arr.Length; i++)
            {
                for (int j = 0; j < arr[i].Length; j++)
                {
                    Console.WriteLine(arr[i][j]);
                }
            }

            int[][][] arr1 = new int[3][][];

        }

        static void TestDuowei()
        {
            int[, ,] arr = new int[3, 4, 5];
        }

        static void TestIf()
        {
            int lwh = 900;
            if (lwh > 1000)  //条件表达式或者是1个bool类型的变量
            {
                Console.WriteLine("中午请吃饭.");
            }
            else if (lwh > 800)
            {
                Console.WriteLine("中餐.");
            }
            else if (lwh > 500)
            {
                Console.WriteLine("小餐.");
            }
            else
            {
                Console.WriteLine("大家请他吃饭....");
            }
            Console.WriteLine("这里是继续往下的代码...");
        }

        static void TestSwitch()
        {
            //switch只能判断等值 ifelse可以判断等值也可以判断范围.
            int score = 78;
            switch (score / 10)
            {
                case 10:
                case 9:
                    Console.WriteLine("A");
                    break;
                case 90:
                    Console.WriteLine("A");
                    break;

            }
        }

        static void TestWhie()
        {
            //while (true)
            //{
            //    Console.WriteLine("A");
            //}
            //do
            //{

            //}while();  
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("A");
                break;//
                continue;
            }
        }

        static void Test2()
        {
            //二维数组表示1个表格  2行3列
            int[,] arr = new int[2, 3];
            //Length属性代表数组的长度 行*列
            //Console.WriteLine(arr.Length);
            //Console.WriteLine(arr[1,1]); 
            //得到指定维度的长度
            arr.GetLength(1);
            for (int i = 0; i < arr.GetLength(0); i++)//2
            {
                for (int j = 0; j < arr.GetLength(1); j++)//3
                {
                    Console.WriteLine(arr[i, j]);
                }
            }
            Console.WriteLine("**************");
            Console.WriteLine(arr.Rank);

            //遍历
            //foreach (int i in arr)
            //{
            //    Console.WriteLine(i);
            //} 



        }

    }
复制代码

 

posted on   努力--坚持  阅读(882)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
点击右上角即可分享
微信分享提示