asp.net-mvcarraysmodeltype-2-dimension

Looping through a two-dimensional array in a asp.net MVC View


My problem is as follows:
I'm making a ranking board for my team. I've managed to get the data out of the database and I put it into a two-dimensional array. I sent it as model data to the view.
Now I don't know how to loop through the two-dimensional array.

Normally it would be something like this:

For Each record in Model
...
Next

How do you loop through two dimensions?

Thanks in advance.


Solution

  • Couldn't you just use two loops?

      For i = 0 To Model.ArrayProperty.GetUpperBound(0)
         For j = 0 To Model.ArrayProperty(i).GetUpperBound(0)
            doWhatever( Model.ArrayProperty(i)(j) )
         Next
      Next