The Any() extension method is part of the System.Linq namepspace. Using this method, you can check whether any of the elements matches a certain condition or not.
Firstly, set an array with elements −
int[] arr = { 6, 7, 15, 40, 55 };The following is an example. It checks whether any of the element in the array is greater than and equal to 20 or not −
arr.Any(element => element >= 20);
Here is the complete code −
Example
using System;
using System.Linq;
class Program {
static void Main() {
int[] arr = { 6, 7, 15, 40, 55 };
bool res = arr.Any(element => element >= 20);
Console.WriteLine(res);
}
}Output
True