

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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# Program to check whether the elements of a sequence satisfy a condition or not
Use All() Method to check whether the elements of a sequence satisfy a condition or not. Even if one of the element do not satisfy the set condition, the All() method returns False.
To set conditions, use Lambda Expressions. Below shows a condition to check whether all the elements are greater than 20 or not.
myArr.AsQueryable().All(val => val > 20);
Let us see an example.
Example
using System; using System.Linq; class Demo { static void Main() { int[] myArr = {7, 15, 22, 30, 40}; // checking if all the array elements are greater than 20 bool res = myArr.AsQueryable().All(val => val > 20); Console.WriteLine(res); } }
Output
False
- Related Questions & Answers
- Program to check whether inorder sequence of a tree is palindrome or not in Python
- C# Program to check whether a directory exists or not
- Java Program to check whether a file exists or not
- How to check whether provided elements in an array have passed a specified condition or not in JavaScript?
- C# Program to check whether a node is a LinkedList or not
- Program to check whether elements frequencies are even or not in Python
- C# program to check whether a list is empty or not
- Python program to check whether a list is empty or not?
- C++ Program to Check Whether a Number is Prime or Not
- C++ Program to Check Whether a Number is Palindrome or Not
- C Program to Check Whether a Number is Prime or not?
- Java Program to Check Whether a Character is Alphabet or Not
- Java Program to Check Whether a Number is Prime or Not
- C# program to check whether a given string is Heterogram or not
- Python program to check whether a given string is Heterogram or not
Advertisements