- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Any Method
The Any method checks whether any of the element in a sequence satisfy a specific condition or not.
If any element satisfy the condition, true is returned.
Let us see an example.
int[] arr = {5, 7, 10, 12, 15, 18, 20};
Now, using Any() method, we will check whether any of the element in the above array is greater than 10 or not.
arr.AsQueryable().All(val => val > 5);
If any of the element satisfies the condition, then True is returned.
Let us see the complete example.
Example
using System; using System.Linq; class Demo { static void Main() { int[] arr = {5, 7, 10, 12, 15, 18, 20}; // checking if any of the array elements are greater than 10 bool res = arr.AsQueryable().Any(val => val > 10); Console.WriteLine(res); } }
Output
True
Advertisements