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

RepeaterItemCollection에서 복사된 항목을 수신하는 0부터 시작하는 Array입니다.

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 개체입니다.

적용 대상

추가 정보