Learn how to execute a for loop in this video.
- [Narrator] In Chapter One when we were introducing…the rules for the project,…I mentioned that it's customary…to roll your scores three times.…This represents an excellent opportunity for me to show you…how to use for-loops inside of C#.…To make the change, I need to go into Character.cs.…If you don't happen to have it open as a tab,…you can find it in your solution explorer…in the character library.…We need to find the method that we created earlier…that rolls the random scores.…
And in my case it's here on line 142.…Remember the objective here is to roll it three times…and then return the best score.…So what I'll do to enact this is to get rid of…what we have in here so far.…Int score equals zero is where I'm going to start.…And then I'm going to make another one…called highest score.…And I'll also set that equal to zero.…Naturally I'm going to want to return highest score,…so I'll change the return to reflect that.…
Now in between these two lines,…we're going to add our for-loop.…Since C# is a C-based language,…
AuthorBruce Van Horn
- Exploring C# on a Mac
- Creating a reusable code library
- Classes and properties
- Loops, arrays, and lists
- Creating a console app
- Creating a command-line app
- Creating a Mac desktop app
- Creating a UI with view controllers and actions
Skill Level Beginner
Docker for .NET Developers with Visual Studiowith Lee Brandt46m 52s Intermediate
1. C# on the Mac?
2. Getting Started with C#
3. Deeper into C#
4. Creating a Mac App
Next steps3m 14s
- 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.