using System;
using System.Collections;
//csc arraylist_capacity.cs
namespace ex_arraylist
{
public class alist
{
ArrayList myS = new ArrayList();
public string sta1 = "";
public string sta2 = "";
public string sta3 = "";
public string sta4 = "";
public string sta5 = "";
public void procss()
{
Console.WriteLine("--Existing Players - " );
// Creates and initializes a new Queue.
//load players name to added
Console.WriteLine("--data - New Players added - " );
Console.Write("Player's Name 1: " );
sta1 = Console.ReadLine();
myS.Add(sta1);
Console.Write("Player's Name 2: " );
sta2 = Console.ReadLine();
myS.Add(sta2);
Console.Write("Player's Name 3: " );
sta3 = Console.ReadLine();
myS.Add(sta3);
Console.Write("Player's Name 4: " );
sta4 = Console.ReadLine();
myS.Add(sta4);
Console.Write("Player's Name 5: " );
sta5 = Console.ReadLine();
myS.Add(sta5);
Console.WriteLine("All Counts :" + myS.Count);
int capacity = myS.Capacity;
Console.WriteLine("---capacity -------" + capacity);
//myS.Sort();
read(myS,'\t');
Console.WriteLine("Search a word from the list ");
String search = Console.ReadLine();
int myfirst = myS.IndexOf( search );
Console.WriteLine( "The first occurrence of \"{0}\" is at index {1}.", search, myfirst );
//myIndex = myAL.LastIndexOf( myString, 8 );
//Console.WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
int mylast = myS.LastIndexOf( search, myS.Count-1);
myS.RemoveAt(mylast);
// add one to match the visula output, as array starts from 0
//visual output starts at 1
Console.WriteLine( "-Removing--" + search + " at : " + (mylast+1) );
read(myS,'\t');
capacity = myS.Capacity;
Console.WriteLine("--altered--capacity -------" + capacity);

} //end of method
public void read(IEnumerable em, char sep)
{
foreach ( Object obj in em )
Console.Write( "{0}{1}", obj,sep );
Console.WriteLine();
}
}

//end of arrylist class
class test
{

static void Main(string[] str)
{Console.Write("Enter a word a evry steps :");
alist at = new alist();
at.procss();
Console.ReadLine();
}//end of the class list
}
}//end of namespace