RepeaterItemCollection.CopyTo(Array, Int32) Метод
Определение
Копирует все элементы из данного класса RepeaterItemCollection в указанный объект Array, начиная с указанного индекса в объекте Array.Copies all the items from this RepeaterItemCollection to the specified Array object, starting at the specified index in the Array object.
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
Отсчитываемый от нуля класс Array, который получает элементы, скопированные из RepeaterItemCollection.A zero-based Array that receives the copied items from the RepeaterItemCollection.
- index
- Int32
Позиция в заданном Array, начиная с которой в него будет помещаться копируемое содержимое.The first position in the specified Array to receive the copied contents.
Реализации
Примеры
Чтобы просмотреть этот код в контексте полного примера, см RepeaterItemCollection . раздел о классе.To see this code in the context of a complete example, see the RepeaterItemCollection class topic.
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 объект, начиная с указанного индекса.Use this method to copy the contents of the RepeaterItemCollection into the specified System.Array object, starting at the specified index.
Примечание
array
Параметр должен быть объектом, начинающимся с нуля System.Array .The array
parameter must be a zero-based System.Array object.