Bool list check if every item in list is false

后端 未结 4 671
轮回少年
轮回少年 2020-12-18 18:28

I have a List with lots of values. What is the most efficient way to check if every single item in the list equals false?

4条回答
  •  失恋的感觉
    2020-12-18 18:49

    You can use LINQ's All method:

    list.All(x => x == false);
    

    This will return false immediately if it finds a value that equals to true.

提交回复
热议问题