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






All 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, 56, 102 };
       Console.Write(numbers.All(e => e % 2 == 0) ? "Yes, they are" : "No, they aren't");
   }
}

 








Related examples in the same category

1.uses All to determine whether an array contains only odd numbers.
2.All with Predicate to Return True
3.All with string length