bool[] isAvailable = new boolean[5];
Initially im setting all values in the array to true.
I'm now changing (one at a time) the values (randomly chosen) to false and I need a way to turn one of the false values back to true if there exists more than 3 false values. Furthermore it must not be the last changed value that becomes true.
I'm using LinQ and C#:
void checkArray() {
if (isAvailable.Where (c => !c).Count () > 3) {
int posOpen = ???;
}
}
Scenario:
[true,true,true,true,true] -> [true,true,true,true,false] ->
[true,true,false,true,false] -> [false,true,false,true,false] ->
[false,true,true,true,false] -> [false,false,true,true,false] etc..
Can anyone explain how-to?
false, dovar falseIndices = Enumerable.Range(0, isAvailable.Length).Select(i => !isAvailable[i]);.