Method Syntax An Query Syntax C# with Example
using System; using System.Linq; namespace CSharpLINQ { class SimpleQuery { static void Main( ) { int[] numbers = { 2, 5, 28, 31, 17, 16, 42 }; var numsQuery = from n in numbers where n < 20 select n; // Query syntax var numsMethod = numbers.Where(x => x < 20); // Method syntax int numsCount = (from n in numbers where n < 20 select n).Count(); // Combined foreach (var x in numsQuery) Console.Write("{0}, ", x); Console.WriteLine(); foreach (var x in numsMethod) Console.Write("{0}, ", x); } } }