CSharp - LINQ to Objects Query

Introduction

IEnumerable<T> is an interface that all the C# generic collection classes implement.

This interface permits the enumeration of a collection's elements.

Demo

using System;  
using System.Linq;  
class Program//  w ww .j  a va2s.c  om
{
    static void Main(string[] args)
    {
        string[] names = {"Python", "Java", "Javascript", "Bash", "C++", "Oracle"};  
          
        string president = names.Where(p => p.StartsWith("J")).First();  
          
        Console.WriteLine(president);  

    }
}

Result

Related Topic