If I have an ArrayList include boolean values, what is the best way to find out the result of this sequence of Bool values ?
I was trying something like this
bool result = false;
bool flag = false;
ArrayList flags = new ArrayList();
if (something > 5)
{
flag = true;
}
flags.Add(flag);
foreach (bool val in flags)
{
result &= val;
}
However if I would declare the result variable as true instead of false, then this changes the result. I am a bit confused.
Any advice would be appreciated!
If you are using &= then the initial value of “result” is very important. If result starts as false, however many times you do &= the result will stay false. If result starts as true, then &= will behave as you expect