Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

LINQ: Extraire les chaînes des caractères qui contiennent un mot, trier le résultat et le mettre en majuscule

LINQ, All, Any, Concat, Contains, Agrégat, Union, Select, Order, From, Where
{filelink=15099}

using System;
using System.Collections.Generic;
using System.Linq;
 
class ExempleSelectOrder
{
    static void Main()
    {
        string[] capitals = { "New York", "Madrid", "Londre", "Milan" };
 
        IEnumerable<string> req =
          from n in capitals
          where n.Contains("M")
          orderby n.Length
          select n.ToUpper();       
 
        foreach (string capital in req)
            Console.Write(capital + "n");
    }
}

No comments yet.

Leave a Comment