Count string starting with H in CSharp

Description

The following code shows how to count string starting with H.

Example


   // w  w  w. j  a  v a2 s.c  o  m

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

public class MainClass {
    public static void Main() {
        string[] presidents = {"HTML", "HTML5", "CSS", "CSS5", "Java", "Javascript"};

        int count = presidents.Count(s => s.StartsWith("H"));
        Console.WriteLine(count);

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ