Click here to Skip to main content
16,011,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,
Is it possible to have access modifiers for get and set method of a property??
Or
Is it only valid at property declaration?

Thanks in advance
Posted
Updated 15-Jan-12 23:13pm
v2

1 solution

Yes - but all access modifiers are set when you declare the item and cannot be changed after that.

Different modifiers are particularly useful with properties, as they allow the outside world to have limited access to your variables.

For example, you might have a string property:
C#
public string Text { get; private set; }
Where the outside world can read the text you are processing at any time, but only the class that created the property can ever modify it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900