Mega Code Archive

 
Categories / C# Book / 04 LINQ
 

0413 Select

Input: IEnumerable<TSource> Lamdbda expression: TSource => TResult or (TSource,int) => TResult Query syntax: select projectionExpression Select returns the same number of elements as the input. using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Program { static void Main() { string[] names = { "Java", "C#", "Javascript", "SQL", "Oracle", "Python", "C++", "C", "HTML", "CSS" }; IEnumerable<string> query = from n in names select n.ToLower(); foreach(String s in query){ Console.WriteLine(s); } } } The output: java c# javascript sql oracle python c++ c html css