How do i get the array beginning instead the end of it?

This is the code in timer1 tick event:

file_indxs = file_indxs - 1;
if (file_indxs < 0)
{
    file_indxs = file_array.Length - 1;
}

file_array.Length - 1 is the end it will beging from the end of the array the last file in the array.

But i want to do :

file_indxs = file_indxs + 1;
if (file_indxs == 0)
{
    file_indxs = the beginning of the array. not the Length - 1
}
Jon Skeet
people
quotationmark

I suspect you actually want:

fileIndex++;
if (fileIndex == fileArray.Length)
{
    fileIndex = 0;
}

(I've changed the variable names to be more conventional at the same time.)

Note the change of condition - if you're incrementing fileIndex, you want to know when you've got to the end, not the beginning.

people

See more on this question at Stackoverflow