Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
Access modifiers are keywords used to specify the accessibility of a class (or type) and its members. These modifiers can be used from code inside or outside the current application.
Access modifiers in .NET are used to control the accessibility of each of the members of a type from different possible areas of code. This can be handled from within the current assembly or outside it. An assembly represents a logical unit of functionality and consists of types and resources located in one or more files.
The purpose of using access modifiers is to implement encapsulation, which separates the interface of a type from its implementation. With this, the following benefits can be derived:
The .NET framework provides an option of having five types of access modifiers:
There are several rules that apply to the access modifiers:
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.