ListItemCollection.CopyTo(Array, Int32) 메서드

정의

지정된 인덱스부터 시작하여 항목을 지정된 ListItemCollection항목 Array 으로 복사합니다.

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

매개 변수

array
Array

에서 복사한 항목을 받는 0부터 시작하는 Array 항목 ListItemCollection입니다.

index
Int32

항목을 받을 지정한 Array 첫 번째 인덱스입니다.

구현

예제

// Copy the items in the ListItemCollection to an array before 
// deleting them.     
ListItem[] myListItemArray = new ListItem[ListBox1.Items.Count];
ListBox1.Items.CopyTo(myListItemArray, 0);

// Delete all the items from the ListBox.
ListBox1.Items.Clear();
DeleteLabel.Text = "<b>All items in the ListBox were deleted successfully." 
    + "</b><br /><b>The deleted items are:";
String listResults="";
    foreach(ListItem myItem in myListItemArray)
    {
        listResults = listResults + myItem.Text + "<br />";
    }
ResultsLabel.Text = listResults;
' Copy the items in the ListListBox1.Items to an array before 
' deleting them.     
Dim myListItemArray(ListBox1.Items.Count - 1) As ListItem
ListBox1.Items.CopyTo(myListItemArray, 0)

' Delete all the items from the ListBox.
ListBox1.Items.Clear()
DeleteLabel.Text = "<b>All items in the ListBox were deleted successfully." & _
                   "</b><br /><b>The deleted items are:"
Dim listResults As [String] = ""
Dim myItem2 As ListItem
For Each myItem2 In myListItemArray
    listResults = listResults & myItem2.Text & "<br />"
Next myItem2
ResultsLabel.Text = listResults

설명

이 메서드를 사용하여 지정된 인덱스에서 시작하여 지정된 ListItemCollection인덱스에 System.Array 내용을 복사합니다.

메모

매개 변수는 array 0부터 System.Array시작해야 합니다.

적용 대상

추가 정보