Welcome to MSDN Blogs Sign in | Join | Help

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; }

}

}

 

Published Thursday, August 17, 2006 5:33 AM by irenak

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker