RepeaterItemCollection.CopyTo(Array, Int32) 메서드

정의

개체의 지정된 인덱스에서 시작하여 이 RepeaterItemCollection 개체의 모든 항목을 지정된 Array 개체에 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 항목 RepeaterItemCollection입니다.

index
Int32

복사된 내용을 받을 지정된 Array 위치의 첫 번째 위치입니다.

구현

예제

전체 예제의 컨텍스트에서 이 코드를 보려면 클래스 항목을 참조 RepeaterItemCollection 하세요.

      void CopyTo_Clicked(Object Sender, EventArgs e)
      {
labelDisplay.Text = "Invoking CopyTo method.<br />";
labelDisplay.Text += "The Items collection contains: <br />";

// Display the elements of the RepeaterItemCollection using the CopyTo method.
RepeaterItemCollection  myItemCollection = myRepeater.Items;
RepeaterItem[] myItemArray = new RepeaterItem[myItemCollection.Count];
myItemCollection.CopyTo(myItemArray,0);
for(int index=0;index < myItemArray.Length;index++)
{
   RepeaterItem myItem = (RepeaterItem)myItemArray.GetValue(index);
   labelDisplay.Text += ((DataBoundLiteralControl)
      myItem.Controls[0]).Text + "<br />";
}
      }
Sub CopyTo_Clicked(Sender As Object, e As EventArgs)
   labelDisplay.Text = "Invoking CopyTo method.<br />"
   labelDisplay.Text += "The Items collection contains: <br />"
   
   ' Display the elements of the RepeaterItemCollection using the CopyTo method.
   Dim myItemCollection As RepeaterItemCollection = myRepeater.Items
   Dim myItemArray(myItemCollection.Count-1) As RepeaterItem
   myItemCollection.CopyTo(myItemArray, 0)
   Dim index As Integer
   For index = 0 To myItemArray.Length - 1
      Dim myItem As RepeaterItem = CType(myItemArray.GetValue(index), RepeaterItem)
      labelDisplay.Text += CType(myItem.Controls(0), DataBoundLiteralControl).Text + "<br />"
   Next index
End Sub 'CopyTo_Clicked

설명

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

메모

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

적용 대상

추가 정보