I was amazed (and horrified) that the following code works in Vb.Net
Dim test2DArr As String(,) = {{"A", "B"}, {"C", "D"}}
For Each s As String In test2DArr
MsgBox(s)
Next
When run, four message boxes pop up showing "A", "B", "C", and then "D".
In other words, it has exactly the same behavior as:
Dim test1DArr As String() = {"A", "B", "C", "D"}
For Each s As String In test1DArr
MsgBox(s)
Next
Can someone explain this "Feature" ? I need to impose some structure here that is apparently not supported. The first code example above should be:
Dim test2DArr As String(,) = {{"A", "B"}, {"C", "D"}}
For Each arr As String(,) In test2DArr
MsgBox(arr(0) & ", " & arr(1))
Next
and should produce two message boxes: "A, B" and "C, D", but the compiler insists that iterating through a 2-d array yields a sequence of strings, not a sequence of arrays of strings.
Am I doing something wrong or is .Net's implementation of 2-D arrays really that flimsy?