C# access modifiers: protected internal vs. protected vs. internal

by Oliver 27. January 2011 22:50

As I just read here on msdn, the modifiers protected and internal are orthogonal as in that they can be specified in all combinations and are combined with a logical OR. This means:

  • protected members are accessible from inheriting classes
  • internal members are accessible from classes within the same assembly
  • protected internal classes are accessible from inheriting classes and all classes from the same assembly

The last option is maybe the most unclear – but just imagine a subclass defined in a different assembly and you’ll see what this might be good for :-)

Happy Coding, Oliver

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.