将序列转换为数组

使用 ToArray 可从序列创建数组。

示例

下面的示例使用 ToArray 直接将查询的计算结果放入数组并获取第三个元素。

var custQuery =
    from cust in db.Customers
    where cust.City == "London"
    select cust;
    Customer[] qArray = custQuery.ToArray();

Dim custQuery = _
    From cust In db.Customers _
    Where cust.City = "London" _
    Select cust
Dim qArray() As Customer = custQuery.ToArray()

请参阅