如果我声明这个数组。
string[,] a = { {"0", "1", "2"}, {"0", "1", "2"}, {"0", "1", "2"}, {"0", "1", "2"}, };
然后我可以用
a.Length
也就是12。我如何测量内部数组的维数? 如果我尝试..。
a[0].Length
我得了 Wrong number of indices inside []; expected 2怎么了?
Wrong number of indices inside []; expected 2
Use System.Array.GetLength(int dimension).
You want the GetLength() method of your array:
a.GetLength(0);
http://msdn.microsoft.com/en-us/library/system.array.getlength.aspx
Use Array.Rank to get number of dimensions and then use Array.GetLength(int dimension) to get the length of a specific dimension.
Array.Rank
Array.GetLength(int dimension)