Is it possible to have different access modifiers on the get/set methods of a property?

Is it possible to have different access modifiers on the get/set methods of a property?

No. 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. 

By:
Date:2011-10-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Links

C interview questions and answers for experienced and fresher