In this case, the C# compiler generates the necessary methods under the hood, as well as a private field, _age .” “To create a property, use the same syntax as for fields, but add a get; to generate a getter and a set; to generate a setter . Then use the property the same as you do a field.”
Read moreHow do I get getters and setters in Visual Studio?
Visual Studio also has a feature that will generate a Property from a private variable. If you right-click on a variable, in the context menu that pops up, click on the “Refactor” item, and then choose Encapsulate Field …. This will create a getter/setter property for a variable.
Read moreWhat is getter setter in C#?
Basically getters and setters are just means of helping encapsulation . When you make a class you have several class variables that perhaps you want to expose to other classes to allow them to get a glimpse of some of the data you store.
Read more