ArrayList.Clone Method (System.Collections)

Switch View :
ScriptFree
ArrayList.Clone Method
Creates a shallow copy of the ArrayList.

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)

Syntax

Visual Basic (Declaration)
Public Overridable Function Clone As Object
Visual Basic (Usage)
Dim instance As ArrayList
Dim returnValue As Object

returnValue = instance.Clone
C#
public virtual Object Clone ()
C++
public:
virtual Object^ Clone ()
J#
public Object Clone ()
JScript
public function Clone () : Object
XAML
Not applicable.

Return Value

A shallow copy of the ArrayList.
Remarks

A shallow copy of a collection copies only the elements of the collection, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new collection point to the same objects that the references in the original collection point to.

In contrast, a deep copy of a collection copies the elements and everything directly or indirectly referenced by the elements.

This method is an O(n) operation, where n is Count.

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
See Also