To Jim Lahman's answer, there's an optimization you can do:
public void DoStuff(int mask)
{
for (int i = 0; mask > 0; mask >>= 1)
{
if ((mask & 1) != 0)
{
array[i].DoSomeOtherStuff();
}
i++;
}
}
This ensures that if your mask is 0000_0101 it will only iterate 3 times until it discovers there's no more bits to be found.
This doesn't allow negatives either, which in my case is what I want.