retrieves all strings in an array whose length matches that of the shortest string : First : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » First »

 

retrieves all strings in an array whose length matches that of the shortest string








    
 

using System;
using System.Collections.Generic;
using System.Linq;
public class MainClass {
    public static void Main() {

        string[] names = { "J", "P", "G", "P" };

        IEnumerable<string> outerQuery = names
          .Where(n => n.Length == names.OrderBy(n2 => n2.Length)
                                        .Select(n2 => n2.Length).First());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» First