Declare and use read write properties in C# Part 3 – Create an instance of the Person class and set values on the object
So finally we’ll create a new instance of the class inside our Main of the TestPerson class. Then we’ll set some values on the object and then increment the property. Time to run the app! Great work Sherlock!
Declare the backing fields Declare the properties Create an instance of the Person class and set values on the object
Let’s continue with our C# programming guide here. This builds on our previous post here on C# classes. First edit the code for the Person class. Remove the constructor that sets the name property and the existing property. Next add the backing fields. Great! Now in the next post we’ll declare the properties.