C# Properties And Auto-Properties

Turning a variable into a property allows more control over how accessible the property is, and the optional addition of functionality on value changes.

Vincent Taylor
2 min readSep 7, 2021
Two examples of Properties (№3 & 4) and two of Auto-properties (№1 & 2) (More on these below)

Properties:

Properties are very similar to normal variables, and can be considered a variant which allows finer control over how accessible the variable is. They also provide the option to add in additional functionality which will be executed when the value is read or set.

When programmers talk about “Getters and Setters”, they are most likely talking about properties. “get” and “set” are the keywords used to create a property.

Two examples of Properties (No.3 & 4) and two of Auto-properties (No.1 & 2) (More on these below)

Auto-Properties:

Something you may not know, or may have heard but not understood, is the term “Auto-Property” or “Auto-Properties”.

Auto-properties are:

  • Variables that allow finer control over how accessible their “read” and “set” functionality is.

And

  • Properties that do not allow any additional functionality to be added when the value is “read” or “set”.

--

--

Vincent Taylor
Vincent Taylor

Written by Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

No responses yet