What are different access modifiers?
There are 5 access modifiers. Access modifiers define scope for members.
- Private: - Accessible only with in the class.
- Protected: -Accessible with in the class and in derived classes.
- Friend (internal in C#): -Accessible anywhere within the current project.
- Protected friend (protected internal in C#): - Accessible with current project and derived classes.
- Public: -Accessible everywhere.
Can we have different access modifiers on get/set methods of a property?
Yes, we can have different access modifiers. The below code will compile perfectly well.
public string CustName
Custname = value;