Answer:
Yes, we can specify the access modifiers for the get and set accessors in a property
Example:
internal string myname
{
private set;
get;
}
This is Ok
Note:
1)The access modifier for the accessor must be more restrictive than that of the property.
private is more restrictive than internal.
2)Both get and set accessors cannot have access modifiers in the same property.
private set and private get would be WRONG in the above example.
Asked In: Many Interviews |
Alert Moderator