C# Access modifiers

Access modifiers are applied on the declaration of the class, method, properties, fields and other members. They define the accessibility of the class and its members.

Access Modifiers Usage
public The Public modifier allows any part of the program in the same assembly or another assembly to access the type and its members.
private The Private modifier restricts other parts of the program from accessing the type and its members. Only code in the same class or struct can access it.
internal The Internal modifier allows other program code in the same assembly to access the type or its members. This is default access modifiers if no modifier is specified.
protected The Protected modifier allows codes in the same class or a class that derives from that class to access the type or its members.
Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *