Q:

How to assign linq anonymous type variable

I have a linq query that gives me an System.Collections.Generic.IEnumerable(of <Anonymous Type>). Actually I wanted to create a class to get better access to what I want form that query but I fail aready with declaring a member variable that should hold the query outcome. The query I use in the Sub New() of my class is (explained and c# version here:)
Dim jan1 = New DateTime(DateTime.Today.Year, 1, 1)
Dim startOfFirstWeek = jan1.AddDays(1 - CInt(jan1.DayOfWeek))
Dim weeks = Enumerable.Range(0, 54).[Select](Function(i) New With { _
    Key .weekStart = startOfFirstWeek.AddDays(i * 7) _
}).TakeWhile(Function(x) x.weekStart.Year <= jan1.Year).[Select](Function(x) New With { _
    x.weekStart, _
    Key .weekFinish = x.weekStart.AddDays(4) _
}).SkipWhile(Function(x) x.weekFinish < jan1.AddDays(1)).[Select](Function(x, i) New With { _
    x.weekStart, _
    x.weekFinish, _
    Key .weekNum = i + 1 _
})

My Class should look like:
Public Class WeekInfo

Private _weeks as ?????

end Class

Could anyone tell me what is the usual procedure to accomplish that task and how to put the find a type for my member to access the weeks variable?

A:

VB.Net anonymous types are exposed as type Object so you're variable would be:
Dim weeks As IEnumerable(Of Object)

You will not get intellisense on the anonymous type's fields outside of the function you created them in but you can access them dynamically, i.e.
For Each week In weeks
    Console.WriteLine(week.weekStart + " " + week.weekFinish)
Next

If you need to expose the type externally you should define a concrete class or struct instead.

