Loop
Loop is a sequence of instructions that is continually repeated until a certain condition is reached. In simple terms Loop is used to execute a group of instructions or a block of code multiple times, without writing it repeatedly. If not handled properly, a loop can cause the computer to become slower as it becomes overwhelmed with repeating the same steps in an infinite loop.
The structure of a Loop can be virtually divided into two parts, namely the control statement, and the body. The control statement of a Loop comprises the conditions that have to be met for the execution of the body of the Loop. For every iteration of the Loop, the conditions in the control statement have to be true. The body of a Loop comprises the block of code or the sequence of logical statements that are to be executed multiple times. Therefore, when you use a Loop in your program, you will not have to write the block of code (written in the body of the Loop), over and over again in it. The block of code will be executed as many times as the control statement will hold true and the Loop will be terminated when the conditions in the control statement become false.
There are 4 types of Loop in C#. we'll study all in detail in coming articles. First let us discuss types of loop.