iterating through an array
- by Farstucker
Iterating though an array isn’t a problem but what if I only wanted to incremented only when the method is called?
Im not even sure if this would work but is there an easier way of doing this
int counter;
string[] myArray = {"foo", "bar", "something", "else", "here"};
private string GetNext()
{
string myValue = string.Empty;
if (counter < myArray.Length) {
myValue = myArray [counter];
} else {
counter = 0;
}
counter++;
return myValue;
}