Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
The accessibility of a member of a type is determined by the type in which it resides and the access modifier specified to it during its declaration. The following are the access modifiers used to specify accessibility:
For example, a type can be declared with a method that has a protected modifier so that it is inaccessible outside the class but accessible to its derived classes.
Not all access modifiers can be used in all contexts by all types. When a member of a type does not include an access modifier during its declaration, its default accessibility is private.
As per the accessibility constraint in C#, several constructs require a type to be at least as accessible as a member or another type. Additionally, if the member is a method, delegate, or indexer, the return type and parameter types must be at least as accessible as the member itself. Use of an inaccessible member will result in a compile time error.