簡體   English   中英

如何在VB.net中找到2D數組中的行數?

[英]How find row count in a 2D array in VB.net?

如何找到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 !

請幫忙 !

GetLength方法可用於查找數組的任何維度的長度。

我相信這段代碼應該適合你:

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'

GetLength(0)將給出2D數組中存在的行數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM