Different access modifiers in C#?

There are four access modifiers in C# which can control the access over the class members and functionalities as a part of data Encapsulation. They are:

  • public - accessible for all classes
  • private - Only accessible within the same class
  • protected - accessible within the same class, or in a class that is inherited from that class.
  • internal - only accessible within its own namespace, but not from another namespace.

There are four access modifiers in C# which can control the access over the class members and functionalities as a part of data Encapsulation. They are:

  • public – accessible for all classes
  • private – Only accessible within the same class
  • protected – accessible within the same class, or in a class that is inherited from that class.
  • internal – only accessible within its own namespace, but not from another namespace.
Sriram Mannava
Sriram Mannava

I'm a full-stack developer and a software enthusiast who likes to play around with cloud and tech stack out of curiosity.

Leave a Reply

Your email address will not be published. Required fields are marked *