i have doubt, can we have different access modifier for get and set in a property.
Thank you,
Yes, you can, however it is subject to the rule that your getter/setter cannot have a less restricted access modifier than the property itself.
For example (C#):
public Foo { get; private set; } //this is okay
protected Bar { get; public set; } //this will throw a compile error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With