Program in ASP.NET: How to Use Loops in ASP.NET


show more Using loops provides you with in-depth training on Developer. Taught by David Gassner as part of the ASP.NET Essential Training show less
please wait ...

Using loops

Both Visual Basic and C# support the concept of looping, executing a bit of code multiple times depending on a particular condition. I'll demonstrate two kinds of loops. For loops and While loops in both languages, starting in C#. I will open the file ProgrammingCSharp. aspx and then I'll save the file under a new name of LoopingCSharp.aspx. A For loop is a loop that executes multiple times and uses a numeric value so that you can increment the value or decrement it each time through the loop. In C# you use a For loop by creating keyword for and then starting with an opening parenthesis you put in three expressions separated with semicolons.

The first expression declares a variable and sets its initial value. I'll create an integer variable named counter and set its initial value to 1. Then, after a semicolon I put in a Boolean expression. This expression will be evaluated each time through the loop and as long as it's true the loop will continue. When the expression is ...

Using loops
Video duration: 6m 52s 6h 24m Beginner Updated Feb 13, 2013

Viewers:

Using loops provides you with in-depth training on Developer. Taught by David Gassner as part of the ASP.NET Essential Training

Subjects:
Developer Web
Software:
ASP.NET
Author:
please wait ...