What is the best way to give a C# auto-property an initial value?

In C# 5 and earlier, to give auto implemented properties an initial value, you have to do it in a constructor. Since C# 6.0, you can specify initial value in-line. The syntax is: DefaultValueAttribute is intended to be used by the VS designer (or any other consumer) to specify a default value, not an initial value. … Read more

Why use getters and setters/accessors?

There are actually many good reasons to consider using accessors rather than directly exposing fields of a class – beyond just the argument of encapsulation and making future changes easier. Here are the some of the reasons I am aware of: Encapsulation of behavior associated with getting or setting the property – this allows additional functionality (like validation) … Read more