Visibility in C#
-
Forget Code
-
C#
-
Visibility
The visibility of a class, a method, a variable or a property tells us how this item can be accessed.
Public:
The member can be reached from anywhere.
This is the least restrictive visibility.
Enums and interfaces are, by default, publicly visible.
Protected:
Members can only be reached from within the same class, or from a class which inherits from this class.
Internal:
Members can be reached from within the same project only.
Protected Internal:
The same as internal, except that also classes which inherits from this class can reach it members, even from another project.
Private:
They can only be reached by members from the same class.
This is the most restrictive visibility.
Classes and structs are by default set to private visibility.
..
Tags for Visibility in C#