Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Values of Boolean array

Tags:

c#

Is there any way how to check if boolean array contains only true (or false) values or i need to check it value by value like this

for (int k = 0; k < 9; k++)
{
   if (CheckPart[k] == false) Checked = false;
}

I know this is simple and works, but only for curiosity.

like image 591
Crooker Avatar asked May 17 '26 01:05

Crooker


1 Answers

The following will return true if all elements are true, otherwise it will return false:

var Checked = CheckedPart.All(p => p);
like image 87
Justin Niessner Avatar answered May 18 '26 14:05

Justin Niessner