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

Computed and read-only properties - Visual Studio Tutorial

From the course: Visual Studio for Mac

Start my 1-month free trial

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…

Contents