There is a ‘forr’ code snippet for reverse ‘for’ loop

Couple of days back we have discussed about one of the hidden and very useful code snippet, ‘propfull – for property and backing field’. Today you will learn another interesting code snippet ‘forr’. Yes, you read it correctly ! ‘forr’ . You must be familiar with ‘for’ code snippet  that generates basic for-loop structure.  Where as, ‘forr’ generates the reverse for-loop .

For an instance if you type   “for”  and then press TAB key twice, a default for-loop will be generated as shown in below. The default loop will have an ‘index’ – i and a max length variable defined as ‘length’


Now, in the case of ‘reverse for-loop’, you can use ‘forr’. That will generate a reverse for-loop as shown below, where you will find a similar index and length variable as general for-loop but in decreasing manner.


Hope you will use it going forward.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.