Access Modifiers
Class Access Modifiers
An access modifier is a keyword that prefixes a class name, and is used to restrict the access to the class.
Below definitions are NOT complete and are shortened for a first-time learner's convenience.
A thorough explanation is found here.
public- Can be accessed from any other class.protected- Can only be accessed by code in the same class, or in a derived class.internal- Can be accessed by any code in the same assembly, but not from another assembly.
public class MyPublicClass
{
}
internal class MyInternalClass
{
}Member Access Modifiers
Within a class, members (such as member variables or methods) must also be declared with an access modifier.
As seen below,
publicmembers can be accessed butprivatemembers cannot.

Last updated