Copies the elements of the ArrayList to a new array of the specified type.
[Visual Basic] Overloads Overridable Public Function ToArray( _ ByVal type As Type _ ) As Array [C#] public virtual Array ToArray( Type type ); [C++] public: virtual Array* ToArray( Type* type ); [JScript] public function ToArray( type : Type ) : Array;
An array of the specified type containing copies of the elements of the ArrayList.
Exception Type | Condition |
---|---|
ArgumentNullException | type is a null reference (in Visual Basic Nothing). |
This method can be overridden by a derived class.
The elements are copied using Copy, which is an O(n) operation.Elements may be downcasted as required. The copy operation may fail if the downcasting is not allowed.
ArrayList Class | ArrayList Members | System.Collections Namespace | ArrayList.ToArray Overload List