Join Gerry O'Brien for an in-depth discussion in this video Using a while loop, part of Up and Running with C#.
- View Offline
- Exercise Files
Now, with the while loop, we have to be very…careful about ensuring that we create something called a sentinel.…A sentinel value is something that we use…to determine when a loop should stop executing.…I've called it sentinel.…This is not a name that you must use.…This is simply a variable name that I've decided to use called sentinel.…And it's an integer type and I have initialized it to zero.…Now, what a while loop does is, it simply checks the condition…at the beginning of the loop, so it says, while the sentinel is…less than ten, I want you to write out the value of the…sentinel and then I want you to increment the sentinel by one value.…
I should have mentioned this earlier in the for loop,…but that plus plus simply means to add one to.…So, sentinel plus plus means take the value of sentinel, in this case zero.…Each time this executes it will add one to the current sentinel value.…It is exactly the same as saying sentinel equals sentinel plus 1.…Alright?…So that's what the plus plus means.…And if you're wondering, does that work with minus minus?…
- Installing C#
- Working with loops
- Controlling program flow
- Using variables
- Building functions
- Creating and instantiating classes
- Catching errors
- Managing resources with the garbage collector
- Building collections
Skill Level Beginner
1. Introducing C#
2. C# Language Elements
3. Object-Oriented Programming in C#
4. Structured Exception Handling
5. Resource Management in C#
6. Extensible Types in C#
7. Windows Apps in C#
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.