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.

Buy Me A Coffee

Found this article helpful? Please consider supporting!

Ram
Ram

I'm a full-stack developer and a software enthusiast who likes to play around with cloud and tech stack out of curiosity. You can connect with me on Medium, Twitter or LinkedIn.

Leave a Reply

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