using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; //csc List_copyto_exists1.cs namespace ConsoleApplication1 { class Program { static void Main(string[] args) { List eList = new List(); eList.Add("A"); 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); } bool b = eList.Exists(x => x == "AD"); Console.WriteLine("eList.Exists(x => x == "+"AD) : "+ b); 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); } } } }