you are viewing a single comment's thread
view the rest of the comments
[–] 8 points 6 months ago (3 children)

Beginner mistake, which is perfectly fine! Just use i-1 inside the loop and i <= values.Length as the condition.

  • source
  • hideshow 3 child comments
  • [–] 3 points 6 months ago (2 children)

    My favorite:

    for (int i = myArray.Length; i --> 0; )
    {
        //do something
    }
    

    Perfectly valid in C-style, even if it does look a bit puzzling at first.

  • source
  • parent
  • hideshow 2 child comments