- 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# All method
The All Method checks for all the values in a collection and returns a Boolean. Even if one of the element do not satisfy the set condition, the All() method returns False.
Let us see an example −
int[] arr = {10, 15, 20};
Now, using All() method, we will check whether each element in the above array is greater than 5 or not.
arr.AsQueryable().All(val => val > 5);
Example
using System; using System.Linq; class Demo { static void Main() { int[] arr = {10, 15, 20}; // checking if all the array elements are greater than 5 bool res = arr.AsQueryable().All(val => val > 5); Console.WriteLine(res); } }
Output
True
Advertisements