Is there a way I can initialize the following runtime array to all trues without looping over it using a foreach?
Here is the declaration:
bool[] foo = new bool[someVariable.Count];
Thanks!
bool[] foo = Enumerable.Repeat(true, someVariable.Count)
.ToArray();
bool[] bools = (new bool[someVariable.Count]).Select(x => !x).ToArray();
Sort of kidding. Kind of. Almost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With