Link is your friend:
var booleans = new List<bool> { true, true, false, true };
bool allPass = booleans.All(p => p);
bool anyPass = booleans.Any(p => p);
bool allFail = booleans.All(p => !p);
bool anyFail = booleans.Any(p => !p);
In fact, it is just foreach, but they are much smaller, and the operations Alland Anyin line with what you need.
p => pis a lambda that returns a boolean. If you, for example, check the nodes that have a method DoesThisPass, you rewrite these checks as follows:
bool allPass = nodes.All(p => p.DoesThisPass());
bool anyPass = nodes.Any(p => p.DoesThisPass());
bool allFail = nodes.All(p => !p.DoesThisPass());
bool anyFail = nodes.Any(p => !p.DoesThisPass());
source
share