How to count only element that match a condition in int array with C#

1 Answer

0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 1, 2, 3, 90, 5, 6, 7 };

            int count = arr.Count(element => element > 3);

            Console.WriteLine(count);
        }
    }
}


/*
run:

4

*/

 



answered Mar 2, 2017 by avibootz
...