Saturday, 2 December 2017

C# Program to Display the Greatest numbers in an Array using WHERE Clause LINQ


Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        int[] numbers = { 500, 344, 221, 4443, 229, 1008, 6000, 767, 256, 0 };
        var greaterNums =
            from num in numbers
            where num > 500
            select num;
        Console.WriteLine("Numbers Greater than 500 :");
        foreach (var s in greaterNums)
        {
            Console.Write(s.ToString() + " ");
        }
        Console.Read();
    }
}


Output:

Numbers Greater than 500 :
4443 1008 6000 767


More C# Programs:





















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...