Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

vb.net

How to find the number of horizontal rows in a 2D array ?

I have :

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

Find the number of rows in i ?

For example :

 // 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 !

Please help !

like image 770
Yugal Jindle Avatar asked Jul 29 '11 08:07

Yugal Jindle


People also ask

How do I count the number of rows in a 2D array?

We use arrayname. length to determine the number of rows in a 2D array because the length of a 2D array is equal to the number of rows it has. The number of columns may vary row to row, which is why the number of rows is used as the length of the 2D array.

How do you find the number of elements in a 2D array?

The number of elements in a 2D array is the number of rows times the number of columns. The code below creates a 2D array with 2 rows and 3 columns named ticketInfo and a 2D array with 3 rows and 2 columns named seatingChart .

How do you find the length of a row and column in a 2D array?

The length of a 2D array is the number of rows it has. The row index runs from 0 to length-1. Each row of a 2D array can have a different number of cells, so each row has its own length : uneven[0] refers to row 0 of the array, uneven[1] refers to row 1, and so on.

Which is the row in a 2D array?

On the exam assume that any 2 dimensional (2D) array is in row-major order. The outer array can be thought of as the rows and the inner arrays the columns.


1 Answers

The GetLength method can be used to find out the length of any dimension of the array.

like image 57
Matti Virkkunen Avatar answered Nov 04 '22 10:11

Matti Virkkunen