In this video, fill in the rest of the properties.
- [Narrator] At the end of the last section I challenged you…to change the code here where I have just…simple fields on lines 21 through 25…and convert those into real properties.…So, let's see how you did.…To do this, in each case, you're going to…need a backing variable that is private.…It's going to match the same type as…the property you're exposing.…And, following my convention,…I'll use an _intelligence.…
After that, we'll come down to the actual…property definition itself and make it into…a property definition by replacing the…semicolon with a set of curly braces.…We'll define our get logic as simply…return _intelligence;…And we'll define our setter using the logic…that you see up there on line 15.…So, it's pretty much the same thing.…
If value is greater than or equal three…and value is less than or equal to 18,…then we'll go ahead and set _intelligence to…the value that got passed in.…Otherwise, we'll throw an error.…And we'll just use the same message we see…up there except it will say…"Intelligence must be between 3 and 18"…
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
New Features Xamarin and Visual Studio 2017with Kevin Ford1h 44m Intermediate
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.