Solved

difference between internal and protected

Posted on 2008-09-29
3
307 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now