How to create a shallow copy of ArrayList in C# Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report ArrayList.Clone() Method is used to create a shallow copy of the specified ArrayList. A shallow copy of a collection copies only the elements of the collection irrespective of 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. Syntax: public virtual object Clone (); Below programs illustrate the use of above-discussed method: Example 1: csharp // C# code to illustrate the use // of ArrayList.Clone Method using System; using System.Collections; public class GFG { // Main Method public static void Main(String[] args) { // Creating an empty ArrayList ArrayList list = new ArrayList(); // Use Add() method // to Add elements // in the list list.Add("Geeks"); list.Add("for"); list.Add("Geeks"); list.Add("10"); list.Add("20"); // Displaying the list Console.WriteLine("Elements of Original ArrayList: \n"); // Displaying the elements in ArrayList foreach(string str in list) { Console.WriteLine(str); } // Creating another ArrayList ArrayList sec_list = new ArrayList(); // using Clone() Method sec_list = (ArrayList)list.Clone(); // Displaying the Cloned ArrayList Console.WriteLine("\nElements of Cloned ArrayList: \n"); // Displaying the elements in ArrayList foreach(string str1 in sec_list) { Console.WriteLine(str1); } } } Output: Elements of Original ArrayList: Geeks for Geeks 10 20 Elements of Cloned ArrayList: Geeks for Geeks 10 20 Example 2: csharp // C# code to illustrate the use // of ArrayList.Clone Method using System; using System.Collections; public class GFG { // Main Method public static void Main(String[] args) { // Creating an empty ArrayList ArrayList list = new ArrayList(); // Use Add() method // to Add elements // in the list list.Add(10); list.Add(20); list.Add(30); list.Add(40); list.Add(50); // Displaying the list Console.WriteLine("Elements of Original ArrayList: \n"); // calling function Result(list); // using Clone() method ArrayList sec_list = (ArrayList)list.Clone(); // Displaying the Cloned ArrayList Console.WriteLine("\nElements of Cloned ArrayList: \n"); // calling function Result(sec_list); // adding a new value to // original ArrayList list.Add(60); Console.WriteLine("\nAfter Adding, Original ArrayList: \n"); // Calling function Result(list); Console.WriteLine("\nAfter Adding, Cloned ArrayList: \n"); // Calling function Result(sec_list); // checking for the equality // of References list and sec_list Console.WriteLine("\nReference Equals: {0}", Object.ReferenceEquals(list, sec_list)); } // method to display the values public static void Result(ArrayList ar) { // This method prints all the // elements in the ArrayList. foreach(int i in ar) Console.WriteLine(i); } } Output: Elements of Original ArrayList: 10 20 30 40 50 Elements of Cloned ArrayList: 10 20 30 40 50 After Adding, Original ArrayList: 10 20 30 40 50 60 After Adding, Cloned ArrayList: 10 20 30 40 50 Reference Equals: False Reference: https://learn.microsoft.com/en-us/dotnet/api/system.collections.arraylist.clone?view=netframework-4.7.2 Create Quiz Comment K Kirti_Mangal Follow 2 Improve K Kirti_Mangal Follow 2 Improve Article Tags : C# CSharp-method CSharp-Collections-Namespace CSharp-Collections-ArrayList Explore IntroductionC# Tutorial 2 min read Introduction to .NET Framework 6 min read C# .NET Framework (Basic Architecture and Component Stack) 6 min read C# Hello World 2 min read Common Language Runtime (CLR) in C# 4 min read FundamentalsC# Identifiers 2 min read Data Types in C# 6 min read C# Variables 4 min read C# Literals 5 min read Operators in C# 7 min read C# Keywords 5 min read Control StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch) 5 min read C# Switch Statement 4 min read Loops in C# 4 min read C# Jump Statements (Break, Continue, Goto, Return and Throw) 4 min read OOP ConceptsClass and Objects in C# 4 min read Constructors in C# 5 min read C# Inheritance 3 min read Encapsulation in C# 2 min read C# Abstraction 4 min read MethodsMethods in C# 4 min read Method Overloading in C# 4 min read Method Parameters in C# 4 min read Method Overriding in C# 7 min read Anonymous Method in C# 2 min read ArraysArrays in C# 6 min read Jagged Arrays in C# 4 min read Array Class in C# 5 min read How to Sort an Array in C# | Array.Sort() Method Set - 1 8 min read How to find the rank of an array in C# 2 min read ArrayListArrayList in C# 6 min read ArrayList Class in C# 4 min read C# | Array vs ArrayList 2 min read StringStrings in C# 6 min read C# Verbatim String Literal - @ 5 min read C# String Class 9 min read C# StringBuilder 2 min read C# String vs StringBuilder 3 min read TupleC# Tuple 7 min read C# Tuple Class 3 min read C# ValueTuple 7 min read C# ValueTuple Struct 4 min read IndexersC# Indexers 5 min read C# Multidimensional Indexers 5 min read C# - Overloading of Indexers 3 min read Like