AutomationElementCollection.CopyTo 方法

定義

從目標陣列之指定的索引開始,將集合的項目複製到陣列。

多載

CopyTo(Array, Int32)

從目標陣列之指定的索引開始,將集合的項目複製到陣列。

CopyTo(AutomationElement[], Int32)

從目標陣列中指定的索引開始,將集合裡的項目複製到指定的陣列執行個體。

CopyTo(Array, Int32)

從目標陣列之指定的索引開始,將集合的項目複製到陣列。

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)

參數

array
Array

從集合複製項目時的目的地。

index
Int32

目標陣列中以零起始的索引 (複製開始之處)。

實作

範例

下列範例示範如何將 複製到 AutomationElementCollection 物件的陣列。

// 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)

適用於

CopyTo(AutomationElement[], Int32)

從目標陣列中指定的索引開始,將集合裡的項目複製到指定的陣列執行個體。

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)

參數

array
AutomationElement[]

從集合複製項目時的目的地。

index
Int32

目標陣列中以零起始的索引 (複製開始之處)。

例外狀況

目的陣列不夠大,或 index 在陣列的界限之外。

範例

下列範例示範如何將 複製到 AutomationElementCollection 物件的陣列 AutomationElement

// 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)

適用於