About ArrayList()

ArrayList


  • The ArrayList is not guaranteed to be sorted
  • The capacity of an ArrayList is the number of elements the ArrayList can hold.
  • As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation.
  • ArrayList accepts nullNothingnullptra null reference (Nothing in Visual Basic) as a valid value and allows duplicate elements.
  • It can support multiple readers concurrently, on condition that the collection is not modified.

/*—————–Sample Program———————*/

using System;

using System.Collections;

namespace ConsoleProgramming

{

class Program

{

static void Main(string[] args)

{

//Intializes a new empty instance of ArrayList Class

//with default initial capacity.

ArrayList al = new ArrayList();

al.Add(“Mayur”); //add String value to ArrayList

al.Add(123); //add Integer value to ArrayList

al.Add(12.13); //add Float value to ArrayList

al.Add(12.12484217584); //add Double value to ArrayList

foreach (var item in al)

{ Console.WriteLine(item); //Print each ‘item’ in ArrayList }

Console.ReadLine();

}

}

}

/*————————————————*/

Regards,
Mayur Dighe
http://ImmortalDotNet.blogspot.com
http://MayurDighe.wordpress.com