C# 多维数组.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

 

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            int[][] myArr = new int[2][];
            myArr[0] = new int[3] { 1, 2, 3 };    //需要说下这是锯齿数组才会有下面的  行.length 的属性,试了标准的多维数组没有这属性的。 声明也不一样是 int[,,] 类型。
            myArr[1] = new int[2] { 4, 5 };
            Console.WriteLine(myArr.Rank);
            for (int i = 0; i < myArr.Length; i++)
            {
                for (int j       = 0; j < myArr[i].Length; j++)
                {
                    Console.WriteLine("行数:{0,-5}列数:{1,-5}值为{2,3}",i,j,myArr[i][j]);

                }
               
            }
        }
    }
}

posted on 2010-10-13 12:07  胖子黎  阅读(313)  评论(0)    收藏  举报

导航