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

I have:

double[,] table = new double[3,4];

How to check both sizes of this table? table.Lengthgives me 12which represents the total number of elements in the table.

+3
source share
3 answers

Use the method GetLength.

So, table.GetLength(0)3 will return, and table.GetLength(1)4 will return.

The parameter for GetLengthis the zero size of the array you want to know.

+8
source

Table.GetLength(0); gives you 3

Table.GetLength(1); gives you 4

Hope this helps.

+5
source

GetLength?

ref

+1
source

Source: https://habr.com/ru/post/1780645/


All Articles