Access Modifiers (C# Reference)
Access modifiers are keywords used to specify the declared accessibility of a member or a type. This section introduces the five access modifiers:
public
protected
internal
private
file
The following seven accessibility levels can be specified using the access modifiers:
public
: Access isn't restricted.protected
: Access is limited to the containing class or types derived from the containing class.internal
: Access is limited to the current assembly.protected internal
: Access is limited to the current assembly or types derived from the containing class.private
: Access is limited to the containing type.private protected
: Access is limited to the containing class or types derived from the containing class within the current assembly.file
: The declared type is only visible in the current source file. File scoped types are generally used for source generators.
This section also introduces the following concepts:
- Accessibility Levels: Using the four access modifiers to declare six levels of accessibility.
- Accessibility Domain: Specifies where, in the program sections, a member can be referenced.
- Restrictions on Using Accessibility Levels: A summary of the restrictions on using declared accessibility levels.
See also
Συνεργαστείτε μαζί μας στο GitHub
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για