Use static method from Enumerable to call the query operators in CSharp

Description

The following code shows how to use static method from Enumerable to call the query operators.

Example


using System;//  ww  w.jav a2  s  .c o  m
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {
        string[] names = { "J", "P", "G", "Pa" };

        IEnumerable<string> filtered = Enumerable.Where(names,n => n.Contains("a"));
        IEnumerable<string> sorted = Enumerable.OrderBy(filtered, n => n.Length);
        IEnumerable<string> finalQuery = Enumerable.Select(sorted,n => n.ToUpper());

    }
}




















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ