ASP.NET Loops and Arrays

In this tutorial I will teach you how to make a loop statement and arrays in ASP.NET.

Included:

For Loops For Each Loops While Loops Arrays

Source Code

For Loops If you need to run the same statements repeatedly, you can make a program that loop. If you know how many times you want to loop, you can use a for loop. This kind of loop is especially useful for counting up or counting down.
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6.         @For i=10 To 21
  7.                 @<p>Line #@i</p>
  8.         Next i
  9. </body>
  10. </html>
For Each Loops If you work with a collection or an array, you often to use a for each loop. A collection is a group of similar objects, and the for each loop lets you carry out a task on each item. The for each loop walks through a collection until it is finished the process.
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <ul>
  5.         @For Each r In Request.ServerVariables
  6.                 @<li>@r</li>
  7.         Next r
  8. </ul>
  9. </body>
  10. </html>
Result And if you want a Full Source Code just Download the file in the download button below. Thanks and I hope you learn it. Enjoy Coding.

Add new comment