If you need to count in a do, while, or foreach loop, you need your own counter.
More than likely, you'll need the results of the count outside of the loop, so it must have a scope outside the loop. In general, then, you count as follows:
int i = 0;
aLoop {
i++;
}
As you go through such a loop, you can count more than one thing. How should be obvious to you.