using System; using System.Collections; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Diagnostics; using System.Linq; //csc CollecT_AsQueryable1.cs namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Collection cTList = new Collection(); cTList.Add("AD"); cTList.Add("B"); cTList.Add("AB"); cTList.Add("C"); cTList.Add("D"); cTList.Add("AD"); cTList.Add("E"); cTList.Add("AD"); Console.WriteLine("Reading List"); readT(cTList); var query1 = cTList.AsQueryable().Select(e => e == "AD"); // Console.WriteLine(" cTList.AsQueryable().Select(e => e ==)" + "AD"); int n1 = 0; foreach (var v1 in query1) { if (v1) { Console.WriteLine("@ " + n1 + " " +v1 );} else { Console.WriteLine("@ " + n1 + " " + v1 );} n1++; } Console.ReadLine(); } static void readT(Collection 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++; } } } }