Solved

difference between internal and protected

Posted on 2008-09-29
3
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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