Edit

Share via


Convert a Sequence to a Generic List

Use ToList to create a generic List from a sequence.

Example

The following sample uses ToList to immediately evaluate a query into a generic List<T>.

var empQuery =
    from emp in db.Employees
    where emp.HireDate >= new DateTime(1994, 1, 1)
    select emp;
    List<Employee> qList = empQuery.ToList();
Dim empQuery = _
    From emp In db.Employees _
    Where emp.HireDate.Value >= #1/1/1994# _
    Select emp
Dim qList As List(Of Employee) = empQuery.ToList()

See also