Search Results

Search found 1 results on 1 pages for 'fairdune'.

Page 1/1 | 1 

  • Decrementing/Incrementing loop variable inside for loop. Is this code smell?

    - by FairDune
    I have to read lines from a text file in sequential order. The file is a custom text format that contains sections. If some sections are out of order, I would like to look for the starting of the next valid section and continue processing. Currently, I have some code that looks like this: for (int currentLineIndex=0; currentLineIndex < lines.Count; currentLineIndex++ ) { //Process section here if( out_of_order_condition ) { currentLineIndex--;//Stay on the same line in the next iteration because this line may be the start of a valid section. continue; } } Is this code smell?

    Read the article

1