ArrayList.CopyTo 메서드

정의

ArrayList 또는 그 일부를 1차원 배열에 복사합니다.

오버로드

CopyTo(Array)

대상 배열의 맨 처음부터 시작하여 전체 ArrayList를 호환되는 1차원 Array에 복사합니다.

CopyTo(Array, Int32)

대상 배열의 지정된 인덱스에서 시작하여 전체 ArrayList을 호환되는 1차원 Array에 복사합니다.

CopyTo(Int32, Array, Int32, Int32)

대상 배열의 지정한 인덱스에서 시작하여 ArrayList의 요소 범위를 호환되는 1차원 Array에 복사합니다.

CopyTo(Array)

Source:
ArrayList.cs
Source:
ArrayList.cs
Source:
ArrayList.cs

대상 배열의 맨 처음부터 시작하여 전체 ArrayList를 호환되는 1차원 Array에 복사합니다.

public:
 virtual void CopyTo(Array ^ array);
public virtual void CopyTo (Array array);
abstract member CopyTo : Array -> unit
override this.CopyTo : Array -> unit
Public Overridable Sub CopyTo (array As Array)

매개 변수

array
Array

Array에서 복사한 요소의 대상인 일차원 ArrayList입니다. Array에는 0부터 시작하는 인덱스가 있어야 합니다.

예외

array이(가) null인 경우

array가 다차원 배열인 경우

또는

소스 ArrayList 요소 수가 대상 array를 포함할 수 있는 요소 수보다 큽니다.

소스 ArrayList의 형식을 대상 array의 형식으로 자동 캐스팅할 수 없습니다.

예제

다음 코드 예제에서는 을 1차원 System.Array로 복사 ArrayList 하는 방법을 보여줍니다.

using namespace System;
using namespace System::Collections;
void PrintValues( array<String^>^myArr, char mySeparator );
int main()
{
   
   // Creates and initializes the source ArrayList.
   ArrayList^ mySourceList = gcnew ArrayList;
   mySourceList->Add( "three" );
   mySourceList->Add( "napping" );
   mySourceList->Add( "cats" );
   mySourceList->Add( "in" );
   mySourceList->Add( "the" );
   mySourceList->Add( "barn" );
   
   // Creates and initializes the one-dimensional target Array.
   array<String^>^myTargetArray = gcnew array<String^>(15);
   myTargetArray[ 0 ] = "The";
   myTargetArray[ 1 ] = "quick";
   myTargetArray[ 2 ] = "brown";
   myTargetArray[ 3 ] = "fox";
   myTargetArray[ 4 ] = "jumps";
   myTargetArray[ 5 ] = "over";
   myTargetArray[ 6 ] = "the";
   myTargetArray[ 7 ] = "lazy";
   myTargetArray[ 8 ] = "dog";
   
   // Displays the values of the target Array.
   Console::WriteLine( "The target Array contains the following (before and after copying):" );
   PrintValues( myTargetArray, ' ' );
   
   // Copies the second element from the source ArrayList to the target ArrayList starting at index 7.
   mySourceList->CopyTo( 1, myTargetArray, 7, 1 );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
   
   // Copies the entire source ArrayList to the target ArrayList starting at index 6.
   mySourceList->CopyTo( myTargetArray, 6 );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
   
   // Copies the entire source ArrayList to the target ArrayList starting at index 0.
   mySourceList->CopyTo( myTargetArray );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
}

void PrintValues( array<String^>^myArr, char mySeparator )
{
   for ( int i = 0; i < myArr->Length; i++ )
      Console::Write( "{0}{1}", mySeparator, myArr[ i ] );
   Console::WriteLine();
}

/* 
 This code produces the following output.
 
 The target Array contains the following (before and after copying):
  The quick brown fox jumps over the lazy dog
  The quick brown fox jumps over the napping dog
  The quick brown fox jumps over three napping cats in the barn
  three napping cats in the barn three napping cats in the barn
 */
using System;
using System.Collections;
public class SamplesArrayList  {

   public static void Main()  {

      // Creates and initializes the source ArrayList.
      ArrayList mySourceList = new ArrayList();
      mySourceList.Add( "three" );
      mySourceList.Add( "napping" );
      mySourceList.Add( "cats" );
      mySourceList.Add( "in" );
      mySourceList.Add( "the" );
      mySourceList.Add( "barn" );

      // Creates and initializes the one-dimensional target Array.
      String[] myTargetArray = new String[15];
      myTargetArray[0] = "The";
      myTargetArray[1] = "quick";
      myTargetArray[2] = "brown";
      myTargetArray[3] = "fox";
      myTargetArray[4] = "jumps";
      myTargetArray[5] = "over";
      myTargetArray[6] = "the";
      myTargetArray[7] = "lazy";
      myTargetArray[8] = "dog";

      // Displays the values of the target Array.
      Console.WriteLine( "The target Array contains the following (before and after copying):" );
      PrintValues( myTargetArray, ' ' );

      // Copies the second element from the source ArrayList to the target Array starting at index 7.
      mySourceList.CopyTo( 1, myTargetArray, 7, 1 );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );

      // Copies the entire source ArrayList to the target Array starting at index 6.
      mySourceList.CopyTo( myTargetArray, 6 );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );

      // Copies the entire source ArrayList to the target Array starting at index 0.
      mySourceList.CopyTo( myTargetArray );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );
   }

   public static void PrintValues( String[] myArr, char mySeparator )  {
      for ( int i = 0; i < myArr.Length; i++ )
         Console.Write( "{0}{1}", mySeparator, myArr[i] );
      Console.WriteLine();
   }
}


/*
This code produces the following output.

The target Array contains the following (before and after copying):
 The quick brown fox jumps over the lazy dog
 The quick brown fox jumps over the napping dog
 The quick brown fox jumps over three napping cats in the barn
 three napping cats in the barn three napping cats in the barn
*/
Imports System.Collections

Public Class SamplesArrayList    
    
    Public Shared Sub Main()
        
        ' Creates and initializes the source ArrayList.
        Dim mySourceList As New ArrayList()
        mySourceList.Add("three")
        mySourceList.Add("napping")
        mySourceList.Add("cats")
        mySourceList.Add("in")
        mySourceList.Add("the")
        mySourceList.Add("barn")
        
        ' Creates and initializes the one-dimensional target Array.
        Dim myTargetArray(14) As String
        myTargetArray(0) = "The"
        myTargetArray(1) = "quick"
        myTargetArray(2) = "brown"
        myTargetArray(3) = "fox"
        myTargetArray(4) = "jumps"
        myTargetArray(5) = "over"
        myTargetArray(6) = "the"
        myTargetArray(7) = "lazy"
        myTargetArray(8) = "dog"
        
        ' Displays the values of the target Array.
        Console.WriteLine("The target Array contains the following " _
           + "(before and after copying):")
        PrintValues(myTargetArray, " "c)
        
        ' Copies the second element from the source ArrayList to the target
        ' Array starting at index 7.
        mySourceList.CopyTo(1, myTargetArray, 7, 1)
        
        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)
        
        ' Copies the entire source ArrayList to the target Array starting
        ' at index 6.
        mySourceList.CopyTo(myTargetArray, 6)
        
        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)
        
        ' Copies the entire source ArrayList to the target Array starting
        ' at index 0.
        mySourceList.CopyTo(myTargetArray)
        
        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)
    End Sub    
    
    Public Shared Sub PrintValues(myArr() As String, mySeparator As Char)
        Dim i As Integer
        For i = 0 To myArr.Length - 1
            Console.Write("{0}{1}", mySeparator, myArr(i))
        Next i
        Console.WriteLine()
    End Sub
    
End Class


' This code produces the following output.
' 
' The target Array contains the following (before and after copying):
'  The quick brown fox jumps over the lazy dog      
'  The quick brown fox jumps over the napping dog      
'  The quick brown fox jumps over three napping cats in the barn   
'  three napping cats in the barn three napping cats in the barn

설명

지정된 된 배열의 호환 되는 형식 이어야 합니다.

이 메서드는 를 사용하여 Array.Copy 요소를 복사합니다.

요소는 열거자가 를 반복하는 순서와 동일한 순서로 에 복사 Array 됩니다 ArrayList.

이 메서드는 작업입니다 O(n) . 여기서 n 은 입니다 Count.

적용 대상

CopyTo(Array, Int32)

Source:
ArrayList.cs
Source:
ArrayList.cs
Source:
ArrayList.cs

대상 배열의 지정된 인덱스에서 시작하여 전체 ArrayList을 호환되는 1차원 Array에 복사합니다.

public:
 virtual void CopyTo(Array ^ array, int arrayIndex);
public virtual void CopyTo (Array array, int arrayIndex);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit
Public Overridable Sub CopyTo (array As Array, arrayIndex As Integer)

매개 변수

array
Array

Array에서 복사한 요소의 대상인 일차원 ArrayList입니다. Array에는 0부터 시작하는 인덱스가 있어야 합니다.

arrayIndex
Int32

array에서 복사가 시작되는 0부터 시작하는 인덱스입니다.

구현

예외

array이(가) null인 경우

arrayIndex가 0보다 작은 경우

array가 다차원 배열인 경우

또는

소스 ArrayList의 요소 수가 대상 arrayarrayIndex부터 끝까지 사용 가능한 공간보다 큽니다.

소스 ArrayList의 형식을 대상 array의 형식으로 자동 캐스팅할 수 없습니다.

예제

다음 코드 예제에서는 을 1차원 System.Array로 복사 ArrayList 하는 방법을 보여줍니다.

using namespace System;
using namespace System::Collections;
void PrintValues( array<String^>^myArr, char mySeparator );
int main()
{
   
   // Creates and initializes the source ArrayList.
   ArrayList^ mySourceList = gcnew ArrayList;
   mySourceList->Add( "three" );
   mySourceList->Add( "napping" );
   mySourceList->Add( "cats" );
   mySourceList->Add( "in" );
   mySourceList->Add( "the" );
   mySourceList->Add( "barn" );
   
   // Creates and initializes the one-dimensional target Array.
   array<String^>^myTargetArray = gcnew array<String^>(15);
   myTargetArray[ 0 ] = "The";
   myTargetArray[ 1 ] = "quick";
   myTargetArray[ 2 ] = "brown";
   myTargetArray[ 3 ] = "fox";
   myTargetArray[ 4 ] = "jumps";
   myTargetArray[ 5 ] = "over";
   myTargetArray[ 6 ] = "the";
   myTargetArray[ 7 ] = "lazy";
   myTargetArray[ 8 ] = "dog";
   
   // Displays the values of the target Array.
   Console::WriteLine( "The target Array contains the following (before and after copying):" );
   PrintValues( myTargetArray, ' ' );
   
   // Copies the second element from the source ArrayList to the target Array, starting at index 7.
   mySourceList->CopyTo( 1, myTargetArray, 7, 1 );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
   
   // Copies the entire source ArrayList to the target Array, starting at index 6.
   mySourceList->CopyTo( myTargetArray, 6 );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
   
   // Copies the entire source ArrayList to the target Array, starting at index 0.
   mySourceList->CopyTo( myTargetArray );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
}

void PrintValues( array<String^>^myArr, char mySeparator )
{
   for ( int i = 0; i < myArr->Length; i++ )
      Console::Write( "{0}{1}", mySeparator, myArr[ i ] );
   Console::WriteLine();
}

/* 
 This code produces the following output.
 
 The target Array contains the following (before and after copying):
  The quick brown fox jumps over the lazy dog
  The quick brown fox jumps over the napping dog
  The quick brown fox jumps over three napping cats in the barn
  three napping cats in the barn three napping cats in the barn

 */
using System;
using System.Collections;
public class SamplesArrayList1  {

   public static void Main()  {

      // Creates and initializes the source ArrayList.
      ArrayList mySourceList = new ArrayList();
      mySourceList.Add( "three" );
      mySourceList.Add( "napping" );
      mySourceList.Add( "cats" );
      mySourceList.Add( "in" );
      mySourceList.Add( "the" );
      mySourceList.Add( "barn" );

      // Creates and initializes the one-dimensional target Array.
      String[] myTargetArray = new String[15];
      myTargetArray[0] = "The";
      myTargetArray[1] = "quick";
      myTargetArray[2] = "brown";
      myTargetArray[3] = "fox";
      myTargetArray[4] = "jumps";
      myTargetArray[5] = "over";
      myTargetArray[6] = "the";
      myTargetArray[7] = "lazy";
      myTargetArray[8] = "dog";

      // Displays the values of the target Array.
      Console.WriteLine( "The target Array contains the following (before and after copying):" );
      PrintValues( myTargetArray, ' ' );

      // Copies the second element from the source ArrayList to the target Array, starting at index 7.
      mySourceList.CopyTo( 1, myTargetArray, 7, 1 );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );

      // Copies the entire source ArrayList to the target Array, starting at index 6.
      mySourceList.CopyTo( myTargetArray, 6 );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );

      // Copies the entire source ArrayList to the target Array, starting at index 0.
      mySourceList.CopyTo( myTargetArray );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );
   }

   public static void PrintValues( String[] myArr, char mySeparator )  {
      for ( int i = 0; i < myArr.Length; i++ )
         Console.Write( "{0}{1}", mySeparator, myArr[i] );
      Console.WriteLine();
   }
}


/*
This code produces the following output.

The target Array contains the following (before and after copying):
 The quick brown fox jumps over the lazy dog
 The quick brown fox jumps over the napping dog
 The quick brown fox jumps over three napping cats in the barn
 three napping cats in the barn three napping cats in the barn

*/
Imports System.Collections

Public Class SamplesArrayList

    Public Shared Sub Main()

        ' Creates and initializes the source ArrayList.
        Dim mySourceList As New ArrayList()
        mySourceList.Add("three")
        mySourceList.Add("napping")
        mySourceList.Add("cats")
        mySourceList.Add("in")
        mySourceList.Add("the")
        mySourceList.Add("barn")

        ' Creates and initializes the one-dimensional target Array.
        Dim myTargetArray(14) As String
        myTargetArray(0) = "The"
        myTargetArray(1) = "quick"
        myTargetArray(2) = "brown"
        myTargetArray(3) = "fox"
        myTargetArray(4) = "jumps"
        myTargetArray(5) = "over"
        myTargetArray(6) = "the"
        myTargetArray(7) = "lazy"
        myTargetArray(8) = "dog"

        ' Displays the values of the target Array.
        Console.WriteLine("The target Array contains the following (before and after copying):")
        PrintValues(myTargetArray, " "c)

        ' Copies the second element from the source ArrayList to the target Array, starting at index 7.
        mySourceList.CopyTo(1, myTargetArray, 7, 1)

        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)

        ' Copies the entire source ArrayList to the target Array, starting at index 6.
        mySourceList.CopyTo(myTargetArray, 6)

        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)

        ' Copies the entire source ArrayList to the target Array, starting at index 0.
        mySourceList.CopyTo(myTargetArray)

        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)

    End Sub

    Public Shared Sub PrintValues(myArr() As String, mySeparator As Char)
        Dim i As Integer
        For i = 0 To myArr.Length - 1
            Console.Write("{0}{1}", mySeparator, myArr(i))
        Next i
        Console.WriteLine()
    End Sub

End Class


' This code produces the following output.
' 
' The target Array contains the following (before and after copying):
'  The quick brown fox jumps over the lazy dog
'  The quick brown fox jumps over the napping dog
'  The quick brown fox jumps over three napping cats in the barn
'  three napping cats in the barn three napping cats in the barn

설명

지정된 된 배열의 호환 되는 형식 이어야 합니다.

이 메서드는 를 사용하여 Array.Copy 요소를 복사합니다.

요소는 열거자가 를 반복하는 순서와 동일한 순서로 에 복사 Array 됩니다 ArrayList.

이 메서드는 작업입니다 O(n) . 여기서 n 은 입니다 Count.

적용 대상

CopyTo(Int32, Array, Int32, Int32)

Source:
ArrayList.cs
Source:
ArrayList.cs
Source:
ArrayList.cs

대상 배열의 지정한 인덱스에서 시작하여 ArrayList의 요소 범위를 호환되는 1차원 Array에 복사합니다.

public:
 virtual void CopyTo(int index, Array ^ array, int arrayIndex, int count);
public virtual void CopyTo (int index, Array array, int arrayIndex, int count);
abstract member CopyTo : int * Array * int * int -> unit
override this.CopyTo : int * Array * int * int -> unit
Public Overridable Sub CopyTo (index As Integer, array As Array, arrayIndex As Integer, count As Integer)

매개 변수

index
Int32

소스 ArrayList에서 복사가 시작되는 인덱스(0부터 시작)입니다.

array
Array

Array에서 복사한 요소의 대상인 일차원 ArrayList입니다. Array에는 0부터 시작하는 인덱스가 있어야 합니다.

arrayIndex
Int32

array에서 복사가 시작되는 0부터 시작하는 인덱스입니다.

count
Int32

복사할 요소의 수입니다.

예외

array이(가) null인 경우

index가 0보다 작은 경우

또는

arrayIndex가 0보다 작은 경우

또는

count가 0보다 작은 경우

array가 다차원 배열인 경우

또는

index가 소스 ArrayListCount보다 크거나 같습니다.

또는

소스 ArrayListindex부터 끝까지에 포함된 요소 수가 대상 arrayarrayIndex부터 끝까지의 사용 가능한 공간보다 큽니다.

소스 ArrayList의 형식을 대상 array의 형식으로 자동 캐스팅할 수 없습니다.

예제

다음 코드 예제에서는 을 1차원 System.Array로 복사 ArrayList 하는 방법을 보여줍니다.

using namespace System;
using namespace System::Collections;
void PrintValues( array<String^>^myArr, char mySeparator );
int main()
{
   
   // Creates and initializes the source ArrayList.
   ArrayList^ mySourceList = gcnew ArrayList;
   mySourceList->Add( "three" );
   mySourceList->Add( "napping" );
   mySourceList->Add( "cats" );
   mySourceList->Add( "in" );
   mySourceList->Add( "the" );
   mySourceList->Add( "barn" );
   
   // Creates and initializes the one-dimensional target Array.
   array<String^>^myTargetArray = gcnew array<String^>(15);
   myTargetArray[ 0 ] = "The";
   myTargetArray[ 1 ] = "quick";
   myTargetArray[ 2 ] = "brown";
   myTargetArray[ 3 ] = "fox";
   myTargetArray[ 4 ] = "jumps";
   myTargetArray[ 5 ] = "over";
   myTargetArray[ 6 ] = "the";
   myTargetArray[ 7 ] = "lazy";
   myTargetArray[ 8 ] = "dog";
   
   // Displays the values of the target Array.
   Console::WriteLine( "The target Array contains the following (before and after copying):" );
   PrintValues( myTargetArray, ' ' );
   
   // Copies the second element from the source ArrayList to the target Array, starting at index 7.
   mySourceList->CopyTo( 1, myTargetArray, 7, 1 );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
   
   // Copies the entire source ArrayList to the target Array, starting at index 6.
   mySourceList->CopyTo( myTargetArray, 6 );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
   
   // Copies the entire source ArrayList to the target Array, starting at index 0.
   mySourceList->CopyTo( myTargetArray );
   
   // Displays the values of the target Array.
   PrintValues( myTargetArray, ' ' );
}

void PrintValues( array<String^>^myArr, char mySeparator )
{
   for ( int i = 0; i < myArr->Length; i++ )
      Console::Write( "{0}{1}", mySeparator, myArr[ i ] );
   Console::WriteLine();
}

/* 
 This code produces the following output.
 
 The target Array contains the following (before and after copying):
  The quick brown fox jumps over the lazy dog
  The quick brown fox jumps over the napping dog
  The quick brown fox jumps over three napping cats in the barn
  three napping cats in the barn three napping cats in the barn

 */
using System;
using System.Collections;
public class SamplesArrayList1  {

   public static void Main()  {

      // Creates and initializes the source ArrayList.
      ArrayList mySourceList = new ArrayList();
      mySourceList.Add( "three" );
      mySourceList.Add( "napping" );
      mySourceList.Add( "cats" );
      mySourceList.Add( "in" );
      mySourceList.Add( "the" );
      mySourceList.Add( "barn" );

      // Creates and initializes the one-dimensional target Array.
      String[] myTargetArray = new String[15];
      myTargetArray[0] = "The";
      myTargetArray[1] = "quick";
      myTargetArray[2] = "brown";
      myTargetArray[3] = "fox";
      myTargetArray[4] = "jumps";
      myTargetArray[5] = "over";
      myTargetArray[6] = "the";
      myTargetArray[7] = "lazy";
      myTargetArray[8] = "dog";

      // Displays the values of the target Array.
      Console.WriteLine( "The target Array contains the following (before and after copying):" );
      PrintValues( myTargetArray, ' ' );

      // Copies the second element from the source ArrayList to the target Array, starting at index 7.
      mySourceList.CopyTo( 1, myTargetArray, 7, 1 );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );

      // Copies the entire source ArrayList to the target Array, starting at index 6.
      mySourceList.CopyTo( myTargetArray, 6 );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );

      // Copies the entire source ArrayList to the target Array, starting at index 0.
      mySourceList.CopyTo( myTargetArray );

      // Displays the values of the target Array.
      PrintValues( myTargetArray, ' ' );
   }

   public static void PrintValues( String[] myArr, char mySeparator )  {
      for ( int i = 0; i < myArr.Length; i++ )
         Console.Write( "{0}{1}", mySeparator, myArr[i] );
      Console.WriteLine();
   }
}


/*
This code produces the following output.

The target Array contains the following (before and after copying):
 The quick brown fox jumps over the lazy dog
 The quick brown fox jumps over the napping dog
 The quick brown fox jumps over three napping cats in the barn
 three napping cats in the barn three napping cats in the barn

*/
Imports System.Collections

Public Class SamplesArrayList

    Public Shared Sub Main()

        ' Creates and initializes the source ArrayList.
        Dim mySourceList As New ArrayList()
        mySourceList.Add("three")
        mySourceList.Add("napping")
        mySourceList.Add("cats")
        mySourceList.Add("in")
        mySourceList.Add("the")
        mySourceList.Add("barn")

        ' Creates and initializes the one-dimensional target Array.
        Dim myTargetArray(14) As String
        myTargetArray(0) = "The"
        myTargetArray(1) = "quick"
        myTargetArray(2) = "brown"
        myTargetArray(3) = "fox"
        myTargetArray(4) = "jumps"
        myTargetArray(5) = "over"
        myTargetArray(6) = "the"
        myTargetArray(7) = "lazy"
        myTargetArray(8) = "dog"

        ' Displays the values of the target Array.
        Console.WriteLine("The target Array contains the following (before and after copying):")
        PrintValues(myTargetArray, " "c)

        ' Copies the second element from the source ArrayList to the target Array, starting at index 7.
        mySourceList.CopyTo(1, myTargetArray, 7, 1)

        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)

        ' Copies the entire source ArrayList to the target Array, starting at index 6.
        mySourceList.CopyTo(myTargetArray, 6)

        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)

        ' Copies the entire source ArrayList to the target Array, starting at index 0.
        mySourceList.CopyTo(myTargetArray)

        ' Displays the values of the target Array.
        PrintValues(myTargetArray, " "c)

    End Sub

    Public Shared Sub PrintValues(myArr() As String, mySeparator As Char)
        Dim i As Integer
        For i = 0 To myArr.Length - 1
            Console.Write("{0}{1}", mySeparator, myArr(i))
        Next i
        Console.WriteLine()
    End Sub

End Class


' This code produces the following output.
' 
' The target Array contains the following (before and after copying):
'  The quick brown fox jumps over the lazy dog
'  The quick brown fox jumps over the napping dog
'  The quick brown fox jumps over three napping cats in the barn
'  three napping cats in the barn three napping cats in the barn

설명

지정된 된 배열의 호환 되는 형식 이어야 합니다.

이 메서드는 를 사용하여 Array.Copy 요소를 복사합니다.

요소는 열거자가 를 반복하는 순서와 동일한 순서로 에 복사 Array 됩니다 ArrayList.

이 메서드는 작업입니다 O(n) . 여기서 n 은 입니다 count.

적용 대상