Learn Basic Access Modifiers in C #

--

Photo by Domenico Loia on Unsplash

What are Access Modifiers?

Access modifiers are simply keywords which are used to give accessibility permissions to classes methods and other members in object oriented programming. In this article we will discuss about access modifiers which are used in C# programming language.

What is the Use of Access Modifiers?

Simply the use of access modifiers are to give permission levels for programs to access other classes, methods and other members(such as variables). If you don’t want a variable, method or class to be accessed by every other members in your program you can use access modifiers to restrict and control the accessibility.

How Many Access Modifiers are there in C#?

In C# there are 6 access modifiers that we can use

  1. Public
  2. Private
  3. Protected
  4. Internal
  5. Protected Internal
  6. Private protected

--

--

Lanka Rathnayaka
Lanka Rathnayaka

No responses yet