From the course: Visual Studio for Mac
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Computed and read-only properties - Visual Studio Tutorial
From the course: Visual Studio for Mac
Computed and read-only properties
- [Instructor] Not every properly constructed property needs to have a backing variable. Sometimes, you want to return a result based on a computation. Let me show you what I mean. I'm going to scroll down to the bottom of my character class, and I'm going to add a new property in here. The property is going to be level, and that determines what the character's level is. Now in the game, the level determines what you can do, so a level one fighter, or a level one magic user, or a level one cleric; they can't do very much, they can only do really basic spells. But as you progress through the game, you get experience points based on what you do. So if you kill a dragon, you get a lot of experience points. If you do something small or simple, you might get a few. But you're always trying to build up your character and level up. And the more you level up, the more fun you're going to have because you're going to get to really cool spells, really cool armor; things like that, that much…
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.
Contents
-
-
-
-
Understanding C# syntax2m 20s
-
Variables and types in C#16m 58s
-
Project rules6m 18s
-
Create a reusable code Library5m 28s
-
Creating a class5m 1s
-
Auto-properties2m 15s
-
Encapsulation8m 15s
-
Finishing remaining properties5m 24s
-
Computed and read-only properties5m 46s
-
Constructors6m 54s
-
Random number method8m 1s
-
Generating the character3m 59s
-
-
-
-