Protected Internal Members … Explained

Protected internal accessibility means protected OR internal, not protected AND internal.

“Protected Internal” acts as "Internal" with in the assembly and Protected" across the assembly. It is used in situations were function needs to be accessed by all the classes within the assembly and all derived classes in other assemblies.

1) Inherited classes, those reside in a different assembly

2) Classes those are not derived, but reside in the same assembly

Have access to Protected Internal Members

Follow the link to download a project that explains the Concept

http://www.4shared.com/file/253782212/f0f6ab9e/ProtectedInternal.html

As per the table below, it is clear that Protected Internal means Protected OR Internal

Scenario Protected Internal Protected Internal
Scenario 1 True True True
Scenario 2 False True True
Scenario 3 True False True
Scenario 4 False False False

Refer the Code and the Table Below

Scenario Comments
Scenario 1 Line42 NS1.cs All functions except Private functions of Base Class were accessible
Scenario 2 Line56 NS1.cs Protected , Private functions of Base Class were not accessible

Public, Internal and Protected Internal functions were accessible.

Scenario 3 Line11 NS2.cs Internal , Private functions of Base Class were not accessible.

Public, Protected and Protected Internal functions were accessible.

Scenario 4 Line25 NS2.cs Only Public Functions were accessible.
Advertisements

1 Comment

  1. Mr WordPress said,

    March 31, 2010 at 4:40 pm

    Hi, this is a comment.
    To delete a comment, just log in, and view the posts’ comments, there you will have the option to edit or delete them.


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

%d bloggers like this: