I’d like to create a list of an anonymous type, for example:
Dim lineItem = New With {.Name = myFile(index).Last_Name & ", " & myFile(index).First_Name, _
.StartDate = myFile(index).Day,
.EndDate = myFile(index).Day}
I have created that anonymous type. Now I’d like to add it to a list of that type. How do I declare a list of that type?
Here’s a handy method for creating a list of an anonymous type from a single anonymous type.
Now you can just do the following
EDIT OP wanted a way to create the list before creating an element.
There are 2 ways to do this. You can use the following code to create an empty list. It borders on hacky because you are passing parameters you don’t ever intend to use but it works.