Share via


SYSK 180: Different Accessor Accessibility

Did you know that you can now give different accessibility modifiers for get and set

 

There are times when you need to allow clients of your class to retrieve data, but not change it…  Now, you can define the set { … } property as more restricted than get { … }

 

For example:

public class Customer

{

private int _id;

public int ID

{

            get { return _id; }

            internal set { _id = value; }

}

}