D
Daniel
Hey guys
i have a array of daya that i wish to iterate through. the only catch is i
need to start from a certain position but on reaching the end of the array
go back to the start and do the rest so that on ever loop every element is
checked in the right order.
For example
int totalCount=0; //to internally track total elements parsed
for(int i=startPos; i<numberOfPlayers; i++)
{
//loop through checking for condition and breaking loop if found
totalCount++;
if(totalCount >= numberOfPlayers) //if we have checked them all stop
looping
break;
else if( startPos.Equals(numberOfPlayers-1) ) //if we reached the
end but have not checked them all restart from beginning
startPos = 0; //to reset to start
}
There must be a better way than the above solution?
thanks
i have a array of daya that i wish to iterate through. the only catch is i
need to start from a certain position but on reaching the end of the array
go back to the start and do the rest so that on ever loop every element is
checked in the right order.
For example
int totalCount=0; //to internally track total elements parsed
for(int i=startPos; i<numberOfPlayers; i++)
{
//loop through checking for condition and breaking loop if found
totalCount++;
if(totalCount >= numberOfPlayers) //if we have checked them all stop
looping
break;
else if( startPos.Equals(numberOfPlayers-1) ) //if we reached the
end but have not checked them all restart from beginning
startPos = 0; //to reset to start
}
There must be a better way than the above solution?
thanks