Can we have different access modifiers for the get and set methods? Justify your answer?

 Posted by Kmandapalli on 1/22/2014 | Category: ASP.NET Interview questions | Views: 5414 | Points: 40
Answer:

The answer is absolutely No because the access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only (by only providing a get accessor) and create a private/internal set method that is separate from the property.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response