- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
All Method in C#
The All() extension method is part of the System.Linq namepspace. Using this method, you can check whether all the elements match a certain condition or not.
Set an array −
int[] arr = { 6, 7, 15, 40, 55 };
The following is an example. It checks whether all the elements in the array is greater than and equal to 2 or not −
arr.All(element => element > = 2);
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.All(element => element >= 2); Console.WriteLine(res); } }
Output
True
- Related Articles
- C# All method
- Print all subsequences of a string using Iterative Method in C++
- What does the all() method do in pandas series?
- Which method must be implemented by all threads in Java?
- Convert.ToChar Method in C#
- Convert.ToDateTime Method in C#
- Convert.ToInt32 Method in C#
- Convert.ToSByte Method in C#
- Convert.ToInt64 Method in C#
- Convert.ToDouble Method in C#
- ContainsKey() method in C#
- Convert.ToString Method in C#
- BinarySearch() method in C#
- Convert.ChangeType Method in C#
- Convert.ToBoolean Method in C#

Advertisements