I have:
double[,] table = new double[3,4];
How 开发者_如何学编程to check both sizes of that table? table.Length
gives me 12
which is total number of elements in table.
Use the GetLength
method.
So table.GetLength(0)
will return 3 and table.GetLength(1)
will return 4.
The parameter for GetLength
is the zero-based dimension of the array you want to know the length of.
Table.GetLength(0);
gives you 3
Table.GetLength(1);
gives you 4
Hope this helps.
GetLength?
ref
精彩评论