All - Simple

Query
public void Linq70()
{
int[] numbers = { 1, 11, 3, 19, 41, 65, 19 };

bool onlyOdd = numbers.All(n => n % 2 == 1);

Console.WriteLine("The list contains only odd numbers: {0}", onlyOdd);
}
Lambda Expression
public void Linq70()
{
int[] numbers = { 1, 11, 3, 19, 41, 65, 19 };

bool onlyOdd = numbers.All(n => n % 2 == 1);

Console.WriteLine("The list contains only odd numbers: {0}", onlyOdd);
}
Output
The list contains only odd numbers: True
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +