namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
// Creates a new ArrayList with five elements and
//initialize each element with a null value.
ArrayList myArray = ArrayList.Repeat(null, 10);
// Displays the count, capacity and values of the ArrayList.
Console.WriteLine("ArrayList with five elements with a null value");
Console.WriteLine(" Count : {0}", myArray.Count);
Console.WriteLine(" Capacity : {0}", myArray.Capacity);
Console.Write(" Values:");
foreach (Object obj in myArray)
Console.Write(" {0}", obj);
Console.WriteLine();
// Creates a new ArrayList with seven elements and
//initialize each element with the string "Repeat".
myArray = ArrayList.Repeat("Repeat", 5);
// Displays the count, capacity and values of the ArrayList.
Console.WriteLine("ArrayList with seven elements with a string value");
Console.WriteLine(" Count : {0}", myArray.Count);
Console.WriteLine(" Capacity : {0}", myArray.Capacity);
Console.Write(" Values:");
foreach (Object obj in myArray)
Console.Write(" {0}", obj);
Console.WriteLine();
}
}
}
|