Do you know that, there exist a snippet to generate reverse 'for' loop?

In this quick tips & trick, we will learn, how to generate reverse for-loop easily, using the Visual Studio code snippet. - Article authored by Kunal Chowdhury on , and was last updated on 2017-08-18T02:30:13Z.

Follow us on:    Twitter  |  Mastodon  |  Facebook  |  WhatsApp  |  Telegram  |  Google News

In every programming language, when you want to loop through a collection, you use the 'for' loop in maximum scenarios. When writing code in Visual Studio, you might be aware that, there exist a code snippet to write the for-loop structure.


But you might not noticed that, there exist another code snippet to generate a reverse for-loop. Let's see what it is and how it operates.


Do you know that, there exist a snippet to generate reverse 'for' loop?


Code snippets are the templates that makes it easier to generate repeating code patterns, such as loops, conditional statements or try-catch exception block. The code snippet 'for' does the same to generate a normal for-loop.


To generate the for-loop structure, write 'for' inside your Visual Studio code editor and press TAB key twice to generate it:

Generate for-loop using the 'for' code snippet

Did you check the book titled 'Mastering Visual Studio 2017'? It covers all the new features introduced in Visual Studio 2017. You can buy the book from Amazon at:


The other code snippet 'forr' is there to create a reverse for-loop structure. In your Visual Studio code editor window, type 'forr' and press TAB key twice. This will result the following code block in the editor:

Generate reverse for-loop using the 'forr' code snippet


I hope that the post was clear and easy to understand. For more posts on Visual Studio Tips & Tricks, stay tuned to this blog.