CodeStatementCollection.CopyTo(CodeStatement[], Int32) Метод

Определение

Копирует элементы объекта CodeStatementCollection в одномерный экземпляр Array начиная с указанного индекса.

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

Параметры

array
CodeStatement[]

Одномерный объект Array, являющийся целевым для значений, скопированных из коллекции.

index
Int32

Индекс в массиве, с позиции которого требуется начать вставку.

Исключения

Массив назначения является многомерным.

-или-

Количество элементов в CodeStatementCollection превышает доступное пространство между индексом конечного массива, указанного параметром index, и концом конечного массива.

Параметр array имеет значение null.

Параметр index меньше, чем минимальный индекс целевого массива.

Примеры

В следующем примере показано, как скопировать содержимое объекта в CodeStatementCollection массив, начиная с указанного значения индекса.

// Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
// 'statements' is a CodeStatement array.
collection->CopyTo( statements, 0 );
// Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
// 'statements' is a CodeStatement array.
CodeStatement[] statementArray = new CodeStatement[collection.Count];
collection.CopyTo( statementArray, 0 );
' Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
' 'statements' is a CodeStatement array.
Dim statementArray(collection.Count - 1) As CodeStatement
collection.CopyTo(statementArray, 0)

Применяется к

См. также раздел