From the course: Advanced C#: Object-Oriented Programming

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Properties

Properties

- [Instructor] Let's continue our review of C# objects by taking a look at defining properties. Now, an important part of class definition is that classes need to be able to perform various types of logic and expose data. Otherwise, you know, they're not very useful. In C#, we use properties and methods to accomplish this. And the word method is a fancy object-oriented way of referring to a function that's part of a class. In fact, we've already seen how to define and use a method in the previous example where we created a function named get area to calculate the area of a rectangle. So let's use that as our starting point for this example. And here in my props and methods folder, I'll open up the shapes code and my program code. And then I'm just going to click on this icon to give us some more room to work. So let's update our example to use properties along with the method that we already have. In addition to methods, C#…

Contents