Clone an ArrayList

In this chapter you will learn:

  1. Clone an ArrayList

Clone an ArrayList

using System;//from  jav  a2s. c  om
using System.Collections;

public class Starter {
    public static void Main(string[] argv) {

        ArrayList al1 = new ArrayList();
        foreach (string arg in argv) {
            al1.Add(int.Parse(arg));
        }
        al1.Sort();
        ArrayList al2 = (ArrayList)al1.Clone();
        for (int count = 0; count < al2.Count; ++count) {
            al2[count] = ((int)al2[count]) * 2;
        }
        foreach (int number in al2) {
            Console.WriteLine(number);

        }
    }
}

Next chapter...

What you will learn in the next chapter:

  1. IsFixedSize and IsReadOnly properties