Suppose I have an array filled with Boolean values and I want to know how many of the elements are true.
private bool[] testArray = new bool[10] { true, false, t
You can use:
int CalculateValues(bool val) { return testArray.Count(c => c == val); }
This handles the true and false checks, based on your val parameter.
true
false
val