如何查找2D数组中的水平行数?
我有:
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 !
请帮忙!
答案 0 :(得分:12)
GetLength方法可用于找出数组任何维度的长度。
答案 1 :(得分:0)
我相信这段代码应该适合你:
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'
答案 2 :(得分:0)
GetLength(0)
将给出2D数组中存在的行数