Rayz.com

Welcome to Rayz.com

C# Access Modifiers

Access Modifiers are keywords used to specify the declared accessibility of a member of a type.

Public

Public is visible to everyone. A public member can be accessed using an instance of a class, by a class’s internal code, and by any descendants of a class.

Private

Private is hidden and usable only by the class itself. No code using a class instance can access a private member directly and neither can a descendant class.

Protected

Protected members are similar to private ones in that they are accessible only by the containing class. However, protected members also may be used by a descendant class. So members that are likely to be needed by a descendant class should be marked protected.

Internal

Internal is public to the entire application but private to any outside applications. Internal is useful when you want to allow a class to be used by other applications but reserve special functionality for the application that contains the class. Internal is used by C# and Friend by VB .NET.

Protected Internal

Protected Internal may be accessed only by a descendant class that’s contained in the same application as its base class. You use protected internal in situations where you want to deny access to parts of a class functionality to any descendant classes found in other applications.