Repeat actions with loops in C#

Beginner
Developer
Higher Education Educator
K-12 Educator
Student
.NET

Learn how to repeat actions in C# using for, while, and do-while loops, and control loop execution with break and continue.

Learning objectives

After you complete this module, you'll be able to:

  • Repeat actions a set number of times using a for loop

  • Repeat actions while a condition is true using a while loop

  • Repeat actions at least once using a do-while loop

  • Control loop execution using break and continue

Prerequisites

  • Beginner level experience with basic C# syntax rules

  • Beginner level experience with displaying a message to a console using the Console.WriteLine() and Console.Write() methods

  • Beginner level experience with creating literal values and declaring variables of basic data types like string, int, and decimal

  • Beginner level experience with evaluating Boolean expressions and using if, else if, and else statements