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#

  1. for loop
  2. while loop
  3. do while
  4. 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.

Related Posts