What are C# Public, Private, Protected?


C# Access Modifiers

In this post, I will talk about the access modifiers available in C#. Access modifiers are commands that allow us to restrict which classes or from where variables or functions can be accessed.

Public 

We can access and modify public data or functions from other classes or other script files.

Private

We can only access private data or functions within the code of that class or script file itself, but we cannot make changes with other classes outside that class.

Protected

We can access and modify protected data or functions only from within that class, but it is not possible to access protected data from any external class.