O'Reilly logo

Begin to Code with C# by Rob Miles

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6. Repeating actions with loops

Image

What you will learn

In this chapter, you’ll learn another step in how to control what a program does. Until now, we’ve written programs that run once and then stop when they’re complete. But you often need to make a program repeat a sequence of actions. For example, if a user enters an invalid value, you want the program to reject that value and repeat the sequence to ask for another value. To repeat a series of actions, programs use what’s known as a loop. In a video game, for example, the “game loop” continuously reads the positions of the game controllers, updates the variables that reflect the status of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required