語言

ParserErrorCollection.CopyTo(ParserError[], Int32) 方法

定義

將 ParserError 集合中的物件複製到相容的一維陣列,從目標陣列指定的索引開始。

public:
 void CopyTo(cli::array <System::Web::ParserError ^> ^ array, int index);
public void CopyTo(System.Web.ParserError[] array, int index);
member this.CopyTo : System.Web.ParserError[] * int -> unit
Public Sub CopyTo (array As ParserError(), index As Integer)

參數

array
ParserError[]

一個型別 ParserError 為 的陣列,將集合中的解析器錯誤複製到該陣列。

index
Int32

這是被複製到 ParserError 的陣列中的第一個索引。

範例

以下程式碼範例示範如何將物件內容 ParserErrorCollection 複製到指定的 ParserError 陣列。

// Copy the contents of the collection to a
// compatible array, starting at index 0 of the
// destination array. 
ParserError[] errorsToSort = new ParserError[5];
collection.CopyTo(errorsToSort, 0);
' Copy the contents of the collection to a
' compatible array, starting at index 0 of the
' destination array. 
Dim errorsToSort(5) As ParserError
collection.CopyTo(errorsToSort, 0)

備註

使用此 CopyTo 方法將集合中的物件(包括它們所包含的項目參考)複製 ParserError 到相容的陣列,從指定的索引開始。 當你想 ParserError 用 該 Sort 方法排序集合中的物件時,這非常有用。 若要這樣做:

  1. 將物件複製 ParserError 到相容的陣列中。

  2. 排序陣列。

  3. 使用該Remove方法將所有物件從集合中移除。ParserError

  4. 使用該 AddRange 方法將排序後的陣列重新加入集合。

適用於