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!
Now it’s time to declare the properties in the Person class. There we go! Now in the last post we’ll create two instances of the Person class and set some values on our two objects.
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.
Something went wrong. Please refresh the page and/or try again.