Any with condition : Any « LINQ « C# / C Sharp






Any with condition

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

public class MainClass{
   public static void Main(){
       int[] numbers = { 2, 6, 1, 5, 10 };
       Console.WriteLine("Is there at least one odd number?");
       Console.Write(numbers.Any(e => e % 2 == 1) ? "Yes, there is" : "No, there isn't");
   }
}

 








Related examples in the same category

1.Any operator with an string array
2.Use Quantifiers: Any
3.Any with string operator
4.Any with false predicate
5.Contains, Any return a bool value