A Loop meaning in programming is to run a block of code multiple times again and again till some occurred condition fails or infinitely.
Types of loops in C#
- for loop
- while loop
- do while
- foreach
Example Scenarios,
- You may want to print numbers from 1 to 1000, then loop can be used.
- If want to get the items from a list one by one
- You may want to read a line from a text file and process each of them
- Or, you may want to continuously monitor some events, if that events occur, then act etc.