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.

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

w

Connecting to %s