Count with string operator : Count « LINQ « C# / CSharp Tutorial






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

public class MainClass {
    public static void Main() {
        string[] presidents = {"G", "H", "a", "H", "over", "Jack"};

        int count = presidents.Count(s => s.StartsWith("H"));
        Console.WriteLine(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