Get First Or Default for string starting with B in CSharp
Description
The following code shows how to get First Or Default for string starting with B.
Example
//from w ww . j a va2 s .co 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", "CSS3", "Java", "XML"};
string name = presidents.FirstOrDefault(p => p.StartsWith("B"));
Console.WriteLine(name == null ? "NULL" : name);
}
}
The code above generates the following result.