Langue

RepeaterItemCollection.CopyTo(Array, Int32) Méthode

Définition

Copie tous les éléments de cet RepeaterItemCollection objet vers l’objet spécifié Array , en commençant à l’index spécifié dans l’objet 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)

Paramètres

array
Array

Base zéro Array qui reçoit les éléments copiés à partir du RepeaterItemCollection.

index
Int32

Première position dans le contenu spécifié Array pour recevoir le contenu copié.

Implémente

Exemples

Pour afficher ce code dans le contexte d’un exemple complet, consultez la RepeaterItemCollection rubrique de classe.

      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

Remarques

Utilisez cette méthode pour copier le contenu de l’objet RepeaterItemCollection spécifié System.Array , en commençant à l’index spécifié.

Note

Le array paramètre doit être un objet de base System.Array zéro.

S’applique à

Voir aussi