Mega Code Archive

 
Categories / C# Book / 04 LINQ
 

0387 The let Keyword

The let keyword introduces a new variable alongside the range variable. using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Program { static void Main() { string[] names = { "Java", "C#", "Javascript" }; IEnumerable<string> query = from n in names let vowelless = n.Replace("a", "").Replace("e", "").Replace("i", "").Replace("o", "").Replace("u", "") where vowelless.Length > 2 orderby vowelless select n; foreach(string s in query){ Console.WriteLine(s); } } } The output: Javascript