课程: Learning C#

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

While loops

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…

内容