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使用该方法将排序的数组添加回集合。

适用于