LINQ: Exemple de ‘Any’ avec condition

Author:

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

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

namespace LINQ
{

public class ExempleAnyCondition
{
   public static void Main()
   {
       int[] nombres = { 3, 9, 14, 1, 17 };
       Console.WriteLine("Il y'a t'il un nombre impair dans la liste? ");
       Console.WriteLine(nombres.Any(e => e % 2 == 1) ? "oui" : "Non");
   }
}

}

Leave a Reply

Your email address will not be published. Required fields are marked *