Chaining Query Operators/extracts all strings containing the letter "a", sorts them by length, and then converts the results to uppercase : Query : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Query »

 

Chaining Query Operators/extracts all strings containing the letter "a", sorts them by length, and then converts the results to uppercase








    
 

using System;
using System.Collections.Generic;
using System.Linq;

class LinqDemo {
    static void Main() {
        string[] names = { "J", "P", "G", "P" };

        IEnumerable<string> query = names
          .Where(n => n.Contains("a"))
          .OrderBy(n => n.Length)
          .Select(n => n.ToUpper());

        foreach (string name in query) Console.Write(name + "|");
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Query