Get First string starting with H in CSharp

Description

The following code shows how to get First string starting with H.

Example


  /* w  w w  . java2s .c  o m*/

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", "java2s.com", "Jack"};

        string name = presidents.First(p => p.StartsWith("H"));
        Console.WriteLine(name);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ