C# Access Modifiers

Knowing what can access your code as you write it and planning out the scope of access for your code is extremely important when it comes to the security of your code. In order to make sure your code is accessed as narrowly as possible increases the security or your code while decreasing the vulnerability at the same time. Here are the default access modifiers found in C#:

Definition: Class(es) => C# objects

Definition: Member(s) => variables, properties, methods

public: any and all code has access to classes or members which are public
private: the class or member is NOT accessible outside of itself  or the class that contains it
protected: the class or member is only accessible by the class that contains it or any class which is a decendant of that class (i.e. subclass)
internal: the class or member is only accessible by code that is within the same assembly (in other words .dll)
protected internal: the class or member is accessible by code in the same assembly (.dll) or by any subclass of that class that contains it.

Published by

Tim Clark

Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s