Solved

difference between internal and protected

Posted on 2008-09-29
3
310 Views
Last Modified: 2010-05-18
i need to understand that difference between the two, to me the definitions I read, make them sound the same...I need to understand this better...
I know there are other...private and stuff...but I dont quite understand the difference between protected and internal.....some non technial explanations please.
0
Comment
Question by:solraccheffy
  • 2
3 Comments
 
LVL 6

Expert Comment

by:wwnosal
ID: 22600513
Hi internal is just visible in files in same assembly unit (usually same project/solution).
Protected is visible in all derived classes (so classes that inherit after the class where you have defined protected members. )

so if you build a library  a put class A there using internal members and then try to derive class A in different project it will not work, however if you use them as a protected ones they will be visible in class derived from A.

Hope this helps
0
 

Author Comment

by:solraccheffy
ID: 22606573
when you say assembly you mean the same dll right? I want to make sure I dont confuse assembly with classes...because aren't there some that only are available in class...as opposed to the entire dll?
I get lost in terminology....just want to have it simplified...like...dervied?
could you clarify a bit more?
also...isnt there another one protectedinternal?
how does that differ?
0
 
LVL 6

Accepted Solution

by:
wwnosal earned 25 total points
ID: 22606887
when I mean same assembly I mean all the files that are linked by the linker to produce your dll or exe  or lib.
internal is then only visible in scope of this built "part".


 If you use protected I mean the following:
lets assume class A that has a protected member m_x.  you have built your lib with class A.
now you are doing new project where you are including this lib with class A in it.
in new project you are declaring class B to be inherited from A like this:

public B : A
{
};

So your protected member (m_x) from base clase A is visible in derived class B..





0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System.Security 2 28
SqlDataBase 7 53
Example works but why do I need to click twice on button 4 48
need to convert function to c# 5 29
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question