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.

C#
public virtual void CopyTo(Array array, int index);

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.

C#
// elementCollection is an AutomationElementCollection.
object[] elementUntypedArray = new object[elementCollection.Count];
elementCollection.CopyTo(elementUntypedArray, 0);

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

CopyTo(AutomationElement[], Int32)

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

C#
public void CopyTo(System.Windows.Automation.AutomationElement[] array, int index);

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.

C#
// elementCollection is an AutomationElementCollection.
AutomationElement[] elementArray = new AutomationElement[elementCollection.Count];
elementCollection.CopyTo(elementArray, 0);

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10