Static property. A static property is similar to a static method. It uses the composite name to be accessed. Static properties use the same get and set tokens as instance properties. They are useful for abstracting global data in programs.

Example. First, this program uses static properties. It shows how to get and set static properties in a static class in a C# program. To use a static property with a backing store field, you must also specify that the backing store be static.

However: The program does not demonstrate this use. It shows the automatically implemented property syntax in the static bool property.

The Settings class is decorated with the static modifier and it cannot be instantiated. It has three static properties. Two of the static properties are read-only and only have the get accessor, while the third is writable as well.

Static classes have a restriction that they cannot be instantiated. This means you are less likely to needlessly create an instance of class that has no state. Static properties are a good function type to put inside a static class.

Note: Many projects use a global variable class that often can be expressed as a static class with static properties.

Tip: Static properties can be accessed with the composite name, using the dot notation.

Discussion. Let's discuss the concept of global variables in programming languages generally and the C# language in specific. Global variables are useful and even functional languages use global environments for binding variables and function names.

However: Global variables can increase complexity and cognitive footprint. This can be dealt with by using accessor routines.

Summary. We looked at static properties in the C# language, seeing how they can be declared in a static class, and then how you can get and set their values. We noted thread-safety issues and one way you can avoid threading problems.