From the course: Learning C#
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
While loops
- In a previous video, we learned about four loops which are usually used to execute a set of program statements for a set number of times. In this video we'll take a look at While loops, which are often used to execute statements for as long as a particular condition exists. So let's take a look at a simple example. So here in my While loops folder, I'll open up the code. So here in my code I have a string variable that I initialize to an empty string and I'm going to create a While loop using the while keyword. So I'm going to do that here and I'm going to write while, and then some parentheses and then the curly braces for my code. So inside the parentheses I need to define the logical expression that's going to be evaluated each time through the loop. So I'm going to have this loop execute while the input Str variable is not equal to the word exit. So I'm going to write while input Str is not equal to exit…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.