数组类型 多维参数

来源:互联网 发布:淘宝图片设计软件 编辑:程序博客网 时间:2024/06/01 09:49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 多维参数
{
    class Program
    {
        static void PrintArray(int[,] arr)
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    System.Console.WriteLine("Element({0},{1}) = {2}", i, j, arr[i, j]);
                    //记住:第一个 i 对应{0},第二个 j 对应{1},第三个arr[i,j]对应{2},就是这样的语法格式。
                }
            }
        }
        static void Main()
        {
            PrintArray(new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } });
            Console.ReadLine();
        }
    }

}


0 0
原创粉丝点击