What is the correct way to query a 2-D array with LINQ.
e.g.
What will be the LINQ equivalent of the following code:
vb.net Code:
Dim myArray(10, 1) As String
'--- Fill the entire array ---
myArray(0, 0) = "some text 0"
myArray(0, 1) = "value 0"
myArray(1, 0) = "some text 1"
myArray(1, 1) = "value 1"
myArray(2, 0) = "some text 2"
myArray(2, 1) = "value 2"
'....
Dim selection As New List(Of ListItem)
For i As Integer = 0 To myArray.GetLength(0) - 1
selection.Add(New ListItem(myArray(i, 0), myArray(i, 1)))
Next
I have tried things like these, but they don't work:
vb.net Code:
Dim selection = From item In myArray _
Select New ListItem With {.Text = item(0), .Value = item(1)}
Dim selection = From item In myArray _
Select New ListItem(item(0), item(1))
Pradeep