Writing queries with methods rather than keywords - CSharp LINQ

CSharp examples for LINQ:IEnumerable

Description

Writing queries with methods rather than keywords

Demo Code



using System;//from   w  w  w .j  a  va 2 s . c o m
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {

        int[] nums = new[] { 5, 7, 1, 4, 9, 3, 0, 2, 6, 8 };
        var tinyNumbers = nums.Where(n => n <= 3)
                     .OrderBy(n => n)
                     .Select(n => n);
        foreach (var n in tinyNumbers)
        { 
           Console.WriteLine("\t\t{0}", n); 
        }

    }
}

Result


Related Tutorials