Blog

A simple example of LINQ

By Mahak Gupta Sep 19 2011
Here we take a simple example of LINQ.
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 8.4k
  • 0
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);
            
        }