語言

EntitySet<TEntity>.CopyTo(TEntity[], Int32) 方法

定義

將 EntitySet<TEntity> 複製到陣列。

public:
 virtual void CopyTo(cli::array <TEntity> ^ array, int arrayIndex);
public void CopyTo(TEntity[] array, int arrayIndex);
abstract member CopyTo : 'Entity[] * int -> unit
override this.CopyTo : 'Entity[] * int -> unit
Public Sub CopyTo (array As TEntity(), arrayIndex As Integer)

參數

array
TEntity[]

要複製到的陣列。

arrayIndex
Int32

陣列中的起始索引。

實作

範例

以下範例展示了此方法的一種使用:

var customer = (from c in db.Customers
   where c.CustomerID == "ALFKI"
   select c).Single();

var orderArray = new Order[customer.Orders.Count];
customer.Orders.CopyTo(orderArray,0);
Dim customer = (From c In db.Customers _
   Where c.CustomerID = "ALFKI" _
   Select c).[Single]()

Dim orderArray As New Order(customer.Orders.Count - 1) {}
customer.Orders.CopyTo(orderArray, 0)

適用於