Is there a cleaner way to invert boolean array?
var myBoolArray=new bool[]{true, true, true, true, true};
bool[] revertedArray=new bool[5];
for(int i=0;i<myBoolArray.Length;i++)
{
revertedArray[i]=!myBoolArray[i];
}
Atm I'm doing this, but it looks really ugly.
new bool[5], How do you know it's length 5? And why is it not based on themyBoolArray.Lenght?bool[]is the worst possible way to store bit data (at least without getting silly); in this case, anint(or even abyte) would be vastly preferable, but for unknown-possibly-large lengths (rather than "at most 32", "at most 64", etc) there'sBitArray, which also has aNot()method; guess whatNot()does!