Home > Coding Helpers > Coding Helpers – Reverse For Loop

Coding Helpers – Reverse For Loop

August 9th, 2012

When working with arrays and lists enumerating all of its items we usually create a for loop statement as follows:

CodeRush Reverse For Loop code sample

But what if we want array items to be listed in reverse? Sometimes, we want to create a loop that starts from a larger number and decrements the iterator variable’s value after each iteration until zero is reached. In this case, we can easily reverse the loop using the Reverse For Loop code provider:

CodeRush Reverse For Loop preview

Once it is applied, it will change the order in which items are enumerated in the loop as illustrated in the preview hint:

CodeRush Reverse For Loop result

The code provider can invert loops written in different kinds of ways in any supported programming language.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Aug/09/2012
ID: C173

Similar Posts: