March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System;
using System.Collections;
namespace Samples
{
public class ArrayListSamples
{
public static void Main()
{
ArrayList a = new ArrayList();
a.Add("damien");
a.Add(42);
a.Add(new object());
Console.WriteLine("-- ArrayList --" );
Console.WriteLine("Count: {0}", a.Count);
Console.WriteLine("Capacity: {0}", a.Capacity );
Console.Write("Values:");
PrintElements(a);
a.Reverse();
Console.Write("Values:");
PrintElements(a);
a.Remove(new object());
a.Remove("damien");
Console.Write("Values:");
PrintElements(a);
}
public static void PrintElements(IEnumerable ie)
{
IEnumerator e = ie.GetEnumerator();
while(e.MoveNext())
Console.Write(" {0}", e.Current );
Console.WriteLine();
}
}
}
-- ArrayList -- Count: 3 Capacity: 16 ...
Read now
Unlock full access