Monday, October 8, 2012

How to Use Arraylist


using System;

using System.Collections;



class Program

{

    static void Main()

    {

 //

 // Create an ArrayList with two values.

 //

 ArrayList list = new ArrayList();

 list.Add(3);

 list.Add(4);

 //

 // Second ArrayList.

 //

 ArrayList list2 = new ArrayList();

 list2.Add(5);

 list2.Add(6);

 //

 // Add second ArrayList to first.

 //

 list.AddRange(list2);

 //

 // Display the values.

 //

 foreach (int i in list)

 {

     Console.WriteLine(i);

 }

    }

}



Output



3

4

5

6

No comments:

Post a Comment