C# ClassesLesson 28Free preview
C# Access Modifiers
This lesson is part of C# · All levels
Summary
The access modifier determines the extent to which a class member can be accessed. The four main modifications are public, private, protected, and internal, with private as default when not written. The correct selection of the modifier hides the internal details while protecting the integrity of the object's data.
Key points
- Public can be accessed from anywhere, private only from within the same class.
- Protected can be accessed by a derivative class, internal from within an assembly or similar project.
- The default modifier of a class member is private when nothing is written.
- Internally protected combines both: derivatives or the same assembly.
- Hiding details with private is the core of encapsulation.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.