Setting entire bool[] to false [duplicate]
If you can re-init array, then answer of Fabian Bigler is the right way to go.
If, however, you want to re-init it to true
, then use Enumerable.Repeat
:
switches = Enumerable.Repeat(true, 20).ToArray();
You can try Array.Clear
as an alternative:
Array.Clear(switches, 0, switches.Length);
Not sure what the relative performance will be, but you should definitely not expect miracles.