Linq Example 30 - Any

11:50 PM
Linq Query: 

 //Any
            int[] intNumbers = { 1, 2, 3, 55, 99, 74, 102 };

            bool bln100to200 = intNumbers.Any(n => (n <= 200 && n >= 100));

            Console.WriteLine(bln100to200);

//

Output:
True
As you can see we want to find if any number is between 100 and 200. All the number except 102 are below 100. so our query return true as it find 102 that satisfy the condition.

0 comments:

Post a Comment