ASP.NET Loops and Arrays

Submitted by: 
Visitors have accessed this post 194 times.

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


For Loops
For Each Loops
While Loops

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>


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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.