#307 – Internal Class Members

Class members marked with the accessibility keyword internal are accessible from within the same class, or from within the code of any classes that exist in the same assembly.

In the picture below, the Dog.DoBark method is marked as internal.  The code in any of the blue blocks can call this method.

Notice that code in the Shepherd class cannot call DoBark, even though it’s in a subclass of Dog.  Also notice that code in OtherClass can call DoBark, even though it’s not a subclass of Dog.  Only code in the same assembly as the Dog class has access to the DoBark method.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #307 – Internal Class Members

  1. Pingback: #1,024 – Exposing internal Members to Another Assembly | 2,000 Things You Should Know About C#

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: