I have a List<bool> with lots of values. What is the most efficient way to check if every single item in the list equals false?
List<bool>
false
You can use Enumerable.Any it will find satisfy the condition on first match. As Habib rightly said better to use Any as Enumerable.All would return true for an Empty list of bool.
Enumerable.Any
!lst.Any(c=> c == true);
OR use Enumerable.All
lst.All(c=> c == false);
1.4m articles
1.4m replys
5 comments
57.0k users