Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Getting count from a LINQ query in C#

Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ForgetCode
{
    class IntroToLINQ
    {
        static void Main()
        {
            // The Three Parts of a LINQ Query: 
            //  1. Data source. 
            int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };

            // 2. Query creation. 
            // numQuery is an IEnumerable<int> 
            var numQuery =
                from num in numbers
                where (num % 2) == 0
                select num;

            // 3. Query execution. 
            
            int evenNumCount = numQuery.Count();

            Console.WriteLine(evenNumCount);

        }
    }
}


Output:
4