From the course: Learning C#

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

For loops

For loops

- Many different kinds of programs often have a need to execute statements multiple times. So for example, a program that reads the rows of a spreadsheet needs to read each row until there aren't any more rows. And a testing program that asks multiple choice questions needs to be able to run through all of its questions before it can complete. So in this video, we're going to take a look at how to build these loops using C-sharp. One way to build a loop in C-sharp is to use the for loop construct. These kinds of loops usually execute a specific number of times. So here in our example code in the for loops folder, I'm going to click on the program file. So to create a for loop, you use the four keyword. And what we're going to do is create a loop. It's going to execute a certain number of commands. So I'll write four and then inside these parentheses, we're going to specify how the loop should execute. So for loops…

Contents