I have declared an anonymous type with 2 elements as follows and later filled it. Code is condensed of course.
public StudentNames
Sub FillStudents()
Dim st = From sts In db.StudentLists Order By studs.Last, studs.First _
Select studs.FullName, studs.StudentId
StudentNames = sts.ToArray
End Sub
How do I get the value of each element
Tried using StudentNames(0,1) and get "Attempted to operate on an array with the incorrect number of dimensions."
I know I could declare StudentNames as a two dimensional array and loop through each st to fill the array, but sts.ToArray is so simple. It works perfect if I use a single dimensioned anonymous type array, but I would like to save the StudentId for later use.
There are a lot of other solutions but this one uses a lot less code both now and later in the program (if I can get it to work).
By the way, I've searched info on anonymous types but they all contain a key, such as:
Dim StudentNames = New With {Key .Name = st.FullName, .Stid = st.StudentId}
which still requires iterating through the query. I would prefer avoiding that if I can.