Numeric Aggregates: count : Count « LINQ « C# / CSharp Tutorial






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

    class Program
    {
        static void Main(string[] args)
        {
            Random generator = new Random(0);
            int[] numbers = new int[1000];
            for (int i = 0; i < 1000; i++)
            {
                numbers[i] = generator.Next();
            }
            var queryResults = from n in numbers where n > 100 select n;

            Console.WriteLine("Count of Numbers > 100");
            Console.WriteLine(queryResults.Count());

        }
    }








22.29.Count
22.29.1.Count with string value
22.29.2.Count with string operator
22.29.3.The aggregation operators return a scalar value
22.29.4.Use Aggregate Operators: Count
22.29.5.Conditional Count
22.29.6.Nested Count
22.29.7.Numeric Aggregates: count
22.29.8.Count elements in a Range