ArrayList 객체의 요소를 새 배열에 복사합니다.
구문
Object.ToArray()
Arguments - Object: 필수. 항상 ArrayList 객체의 이름입니다.
반환
ArrayList 객체의 요소 복사본을 포함하는 배열입니다.
주석
다음 예에서는 ToArray 메소드의 사용을 보여 줍니다.
예 1:
'Create ArrayList Object
Dim Obj
Set Obj = CreateObject("System.Collections.ArrayList")
'Add Elements to the end of ArrayList Object
Dim Index
Index = Obj.Add(10)
Index = Obj.Add(40)
Index = Obj.Add(20)
Index = Obj.Add(30)
'Copies the elements of the ArrayList object to a new array
Dim ArrObj
ArrObj = Obj.ToArray()
'Display Elements from Array
For Each Element In ArrObj
'Operation based on requirement using each element of Array
Next
'Output: ArrObj contains 10, 40, 20, 30