获取多维数组的维数和行数

获取多维数组的维数和行数

1 int[,,] a =new int[10,11,12]; 
2 Console.WriteLine(a.Length);           // 1320 
3 Console.WriteLine(a.GetLength(0));     // 10 
4 Console.WriteLine(a.GetLength(1));     // 11 
5 Console.WriteLine(a.GetLength(2));     // 12

 

多维数组的声明:

1 string[,] book_arr = new string[,] { { "English",  "101" }, 
2                                                  { "History",  "102" }, 
3                                                  { "Computer", "103" },
4                                                  { "Algorithm","104" } };

 

posted @ 2012-10-24 17:59  zp_Alex  阅读(594)  评论(0编辑  收藏  举报