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.

Showing Answers 1 - 4 of 4 Answers

reenaganesh

  • Apr 11th, 2006
 

This is possible in the current version of .NET 2.0.

For example: The property is public and the set accessor can be made protected.

  Was this answer useful?  Yes

Sunny

  • Jul 7th, 2007
 

Also in new version of DOTNET it is allowed
and to set the variable we can use protected as access modifier

  Was this answer useful?  Yes

yes,it is possible for get and set to have different access modifiers,but one of the accessors must follow the access level of property.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions