This has been driving me crazy for a few days. Why doesn’t the following work?
Dim arr(3, 3) As Integer For y As Integer = 0 To arr.GetLength(0) - 1 For x As Integer = 0 To arr.GetLength(y) - 1 arr(y, x) = y + x Next Next
Also, what if the array looked like this instead?
{ {1, 2, 3}, {4, 5, 6, 7, 8, 9, 9, 9}, {5, 4, 3, 2} }
Ok, so what you really need is a ‘jagged array’. This will allow you to have an ‘array that contains other arrays of varying lengths’.
Output: