Επεξεργασία

Κοινή χρήση μέσω


AutomationElementCollection.CopyTo Method

Definition

Copies the collection's elements to an array, starting at the specified index in the target array.

Overloads

CopyTo(Array, Int32)

Copies the collection's elements to an array, starting at the specified index in the target array.

CopyTo(AutomationElement[], Int32)

Copies the collection's elements to a specialized array instance, starting at the specified index in the target array.

CopyTo(Array, Int32)

Copies the collection's elements to an array, starting at the specified index in the target array.

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

Parameters

array
Array

The destination of the elements copied from the collection.

index
Int32

The zero-based index in the target array where copying should begin.

Implements

Examples

The following example shows how to copy an AutomationElementCollection to an array of objects.

// elementCollection is an AutomationElementCollection.
object[] elementUntypedArray = new object[elementCollection.Count];
elementCollection.CopyTo(elementUntypedArray, 0);
' elementCollection is an AutomationElementCollection.
Dim elementUntypedArray(elementCollection.Count) As Object
elementCollection.CopyTo(elementUntypedArray, 0)

Applies to

CopyTo(AutomationElement[], Int32)

Copies the collection's elements to a specialized array instance, starting at the specified index in the target array.

public:
 void CopyTo(cli::array <System::Windows::Automation::AutomationElement ^> ^ array, int index);
public void CopyTo (System.Windows.Automation.AutomationElement[] array, int index);
member this.CopyTo : System.Windows.Automation.AutomationElement[] * int -> unit
Public Sub CopyTo (array As AutomationElement(), index As Integer)

Parameters

array
AutomationElement[]

The destination of the elements copied from the collection.

index
Int32

The zero-based index in the target array where copying should begin.

Exceptions

The destination array is not large enough, or index is outside the bounds of the array.

Examples

The following example shows how to copy an AutomationElementCollection to an array of AutomationElement objects.

// elementCollection is an AutomationElementCollection.
AutomationElement[] elementArray = new AutomationElement[elementCollection.Count];
elementCollection.CopyTo(elementArray, 0);
' elementCollection is an AutomationElementCollection.
Dim elementArray(elementCollection.Count) As AutomationElement
elementCollection.CopyTo(elementArray, 0)

Applies to