A simple example of LINQ

Here we take a simple example of LINQ. We just compare a number with a number of digits:

 int[] digits = { 5, 4, 1, 7, 9, 8, 6, 7, 4, 5 };

        var num =
            from n in digits
            where n >= 6
            select n;


        Console.WriteLine("Numbers < 5:");
        
        foreach (var x in num)
        {
            Response.Write(x);
            
        }
Ebook Download
View all
Learn
View all