Solved

difference between internal and protected

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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