namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
// Creates a new ArrayList
ArrayList myArray = new ArrayList();
myArray.Add("Hi");
myArray.Add("How");
myArray.Add("Are");
myArray.Add("You");
myArray.Add("Hi");
myArray.Add("Have");
myArray.Add("a nice");
myArray.Add("Day");
myArray.Add("Hi");
// Displays the values of the ArrayList.
Console.WriteLine("The ArrayList contains the following values:");
foreach (string s in myArray)
{
Console.WriteLine(s);
}
// Searches for the last occurrence of the value.
String myString = "Hi";
int myIndex = myArray.LastIndexOf(myString);
Console.WriteLine("The last occurrence of \"{0}\" is at index {1}.", myString, myIndex);
}
}
}