如何找到行计数在一个二维数组在VB.net



如何查找二维数组中的水平行数

我有:

   Dim i(,) As Integer = {{2, 5, 6, 7}, {32, 5, 4, 2}}

查找i中的行数

例如:

 // Here, array i has 2 sets of data i.e. 2 rows
 // set1 = {2,5,6,7} and set2 = {32,5,4,2}
 // So, I want the number of sets i.e 2 in this case !

GetLength方法可用于查找数组的任何维度的长度

GetLength(0)将给出2D数组中存在的行数

我相信这段代码应该适合你:

Dim array(56,67) As Integer 'Example array'
Dim x_axis As Integer = array.GetLength(0)-1 'To find out number of dimensions on the x'
Dim y_axis As Integer = array.GetLength(1)-1 'To find out number of dimensions on the y'

最新更新