CSharp - Use condition with Count operator

Description

Use condition with Count operator

Demo

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program//from  w  ww . j  a v a 2s. c  o  m
{
    static void Main(string[] args)
    {
        string[] codeNames = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"};
        
        int count = codeNames.Count(s => s.StartsWith("J"));
        Console.WriteLine(count);
    }
}

Result

Related Topic