Add an object to the end of the ArrayList in CSharp

Description

The following code shows how to add an object to the end of the ArrayList.

Example


using System;/*from   w ww . j  a  va  2  s.  c om*/
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program {
    static void Main(string[] args) {
        ArrayList myList = new ArrayList();
        myList.Add("s");
        myList.Add("r");
        myList.Add("java2s.com");

        foreach (string item in myList) {
            Console.Write(item + "\n");
        }

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary