Check if an int array has event value with All in CSharp

Description

The following code shows how to check if an int array has event value with All.

Example


// w  w  w .  java 2s  . c o m
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");
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ