using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; //csc ListRemoveAt1.cs namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List eList = new List(); eList.Add("AD"); eList.Add("B"); eList.Add("AB"); eList.Add("C"); eList.Add("D"); eList.Add("AD"); eList.Add("E"); eList.Add("AD"); // eList.Sort(); //Copies the entire List to a compatible one-dimensional array, //starting at the specified index of the target array Console.WriteLine("Reading List"); readT(eList); Console.WriteLine("Feeding string array : CopyTo"); //eList.RemoveAll(s=>s =="AD"); eList.RemoveAt(3); readT(eList); Console.ReadLine(); } static void readT(IList list) { //notice that the list is passed an IList and hence can handle both types of lists //Use IEnumerable int n1 = 0; foreach (string val in list) { Console.WriteLine("index " + n1 + " string " + val); n1++; } } } }