C# and Lambda – Finding all the elements of an integer array less than 35

Here’s a sample code snippet demonstrating how to find all the elements of an integer array that is less than 35 using Lambda expression in C#.

The Where keyword in C# is used to filter the elements from a collection based on the specified criteria.

How to find all the elements of an integer array less than 35 using Lambda expression in C# ?

using System.Diagnostics;
using System.Linq;

namespace AbundantcodeCsharpSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = { 78,5,23,67,11,23 };
            // find all the numbers greater than 35 using Lambda
            var output = input.Where(a => a > 35);
            Debug.WriteLine("Numbers Greater than 35");
            foreach (var item in output)
                Debug.WriteLine(item);
        }
    }
}

The output of the program is

Numbers Greater than 35

78

67

%d