Share via


ParserErrorCollection.CopyTo(ParserError[], Int32) メソッド

定義

コピー先配列の指定されたインデックスを開始位置として、コレクション内の ParserError オブジェクトを互換性がある 1 次元配列にコピーします。

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並べ替えられた配列をコレクションに追加するには、 メソッドを使用します。

適用対象