using System;
using System.Collections; // for non generic collections like ArrayList
namespace Console_ArrayList
{
class Program
{
static void Main(string[] args)
{
ArrayList arrList = new ArrayList();
arrList.Add(2);
arrList.Add(4);
arrList.Add(7);
arrList.Add("Ajeet");
arrList.Add("Rajeev");
int[] array1 = { 1, 3, 5, 8, 6, 9 };
arrList.AddRange(array1); //AddRange adds an array
Console.WriteLine("List of all added heterogeneous items to ArrayList");
foreach (var item in arrList)
{
Console.WriteLine(item);
}
Console.ReadKey();
}
}
}
OUTPUT
List of all added heterogeneous items to ArrayList
2
4
7
Ajeet
Rajeev
1
3
5
8
6
9
No comments:
Post a Comment