Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

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

0
Posted

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

0

No. The access modifier on a property applies to both it’s get and set accessors. What you probably want to do if you need them to be different is make the property read-only (by only providing a get accessor) and creating a private/internal set method separate from the property.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123