© Mikael Olsson 2018
Mikael OlssonC# 7 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-3817-2_13

13. Access Levels

Mikael Olsson1 
(1)
Hammarland, Länsi-Suomi, Finland
 

Every class member has an accessibility level that determines where the member will be visible. There are six of them available in C#: public, protected, internal, protected internal, private, and private protected, the last of which was added in C# 7.2. The default access level for members of a class is private.

Private Access

All members regardless of access level are accessible in the class in which they are declared, the defining class. This is the only place where a private member can be accessed.
public class MyBase
{
  // Unrestricted access
  public int myPublic;
  // Defining ...

Get C# 7 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.