Add the elements of an ICollection to the end of the ArrayList in CSharp

Description

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

Example


using System;//from ww  w  .  j  a  va2s.  c o m
using System.Collections;
using System.Collections.Generic;
using System.Text;

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

        string[] myStringArray = new string[2];
        myStringArray[0] = "G";
        myStringArray[1] = "L";

        baseballTeams.AddRange(myStringArray);

        foreach (string item in baseballTeams) {
            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