开发者

How to check sizes of two (or more) dimensional array in C#?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜