Declare and use read write properties in C# Part 1 – Declare the backing fields

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.

        private string _name = "N/A";
        private int _age = 0;

Great! Now in the next post we’ll declare the properties.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: