using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; //csc List_FindAll1.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"); int n1 = eList.Count(); eList.Sort(); //Copies the entire List to a compatible one-dimensional array, //starting at the specified index of the target array String[] eList2 = new String[eList.Count()]; eList.CopyTo(eList2,0); Console.WriteLine("Reading List"); readT(eList); Console.WriteLine("Feeding string array : CopyTo"); foreach(string str in eList2) { Console.WriteLine(str); } List b = eList.FindAll(s => s == "AD"); IEnumerable c = b; Console.WriteLine("eList.FindAll(s => s =="+ "AD"); foreach (Object str1 in c) { Console.WriteLine(str1); } 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 foreach (string val in list) { Console.WriteLine(val); } } } }