Share via


How to: Convert a Sequence to an Array (LINQ to SQL)

Use ToArray<TSource> to create an array from a sequence.

Example

The following example uses ToArray<TSource> to immediately evaluate a query into an array and to get the third element.

Dim custQuery = _
    From cust In db.Customers _
    Where cust.City = "London" _
    Select cust
    Dim qArray() As Customer = custQuery.ToArray()
var custQuery =
    from cust in db.Customers
    where cust.City == "London" 
    select cust;
    Customer[] qArray = custQuery.ToArray();

See Also

Other Resources

Query Examples (LINQ to SQL)