C# language feature:

  • Getter and setter separate accessibility

applies to

  • class properties

benefit

  • Limits accessibility (as desired) to properties (where desired), typically in setting a property.

how to use

  • Precede the set or get with a modifier keyword such as protected

example:

    public class Getter_and_Setter_Accessibility_Example
    {
        public int ExampleProperty
        {
            // Ability to restrict further the accessor accessibility level.
            protected set { }

            // No access modifier.
            get { return 0; }
        }
    }