Page 47 数组代码

namespace CH02
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] languages;
            languages = new string[] { "1" };
            int[] style1 = new int[1];
            style1 = new int[] { 1 };
            int[] style2 = new int[] { 2 };
            int[] style3 = new int[2] { 2, 3 };
            int[] style4 = new int[1];
            style4 = new int[] { 1 };
            int[][,] style5 = new int[][,]
            { 
                new int[,] {{1},{1}}, 
                new int[,] {{2},{2}},
                new int[,] {{2,22},{3,33},{4,44},{5,55}}
            };
            System.Console.WriteLine(style5.Length);
            System.Console.WriteLine(style5[2].Length);
            System.Console.WriteLine(style5[2][3, 1]);

            bool[, ,] cells = new bool[2, 3, 4];
            // 第0维的长度2 
            // 第1维的长度3
            // 第2维的长度4
            System.Console.WriteLine(cells.GetLength(2));
            // 返回维数
            // cells.Rank
            // cells.Clone()返回一个副本
            bool[, ,] copyCells = (bool[,,])cells.Clone();

            System.Console.ReadKey(true);
        }
    }
}
posted @ 2011-11-29 15:10  jacky_j2ee  阅读(110)  评论(0编辑  收藏  举报