By Team Escalera
on 19 Dec 2017 01:06 PM
  • Type of Loop in C#
0 comments

1. while loop

It repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the loop body.

Syntax:    while(condition) { statement(s); }

2. for loop

It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable

 

Syntax: for(initialization; condition; step) code statement

3. do...while loop

It is similar to a while statement, except that it tests the condition at the end of the loop body

Syntax: 
do {
   statement(s);
} while( condition );

4.nested loops

You can use one or more loop inside any another while, for or do..while loop

Syntax: 
for ( init; condition; increment ) {
   for ( init; condition; increment ) {
      statement(s);
   }
   statement(s);
}

 

Comments (0)

Leave A Comment