Επεξεργασία

Κοινή χρήση μέσω


ParserErrorCollection.CopyTo(ParserError[], Int32) Method

Definition

Copies the ParserError objects in the collection to a compatible one-dimensional array, starting at the specified index of the target array.

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)

Parameters

array
ParserError[]

An array of type ParserError to which the parser errors in the collection are copied.

index
Int32

The first index within the array to which the ParserError is copied.

Examples

The following code example demonstrates how to copy the contents of a ParserErrorCollection object to the specified ParserError array.

// 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)

Remarks

Use the CopyTo method to copy the ParserError objects in a collection (including the item references they contain) to a compatible array, starting at a specified index. This is useful when you want to sort the ParserError objects in the collection by using the Sort method. To do this:

  1. Copy the ParserError objects into a compatible array.

  2. Sort the array.

  3. Use the Remove method to remove all the ParserError objects from the collection.

  4. Use the AddRange method to add the sorted array back to the collection.

Applies to