To getting how many data are available with matched first letter data in LINQ.

Jitendrasoft09
Posted by Jitendrasoft09 under C# category on | Points: 40 | Views : 570
using System;
using System.Collections.Generic;
using System.Linq;

class jkexample {

static void Main(string[] args) {


List<string> listobject = new List<string>() {
"bca","mca", "dca", "adca" ,
};


char firstLetter = 'b';


int resultCount = listobject
.Where(e => e[0] == firstLetter)
.Select(e => e).Count();


Console.WriteLine("Result count: {0}", resultCount);


Console.ReadLine();
}
}

Comments or Responses

Login to post response