Click here to Skip to main content
15,884,629 members
Home / Discussions / C#
   

C#

 
Questionis a File Read Only. Pin
Saqib Mehmood5-Aug-07 22:32
Saqib Mehmood5-Aug-07 22:32 
AnswerRe: is a File Read Only. Pin
N a v a n e e t h5-Aug-07 22:53
N a v a n e e t h5-Aug-07 22:53 
AnswerRe: is a File Read Only. Pin
Nouman Bhatti6-Aug-07 2:05
Nouman Bhatti6-Aug-07 2:05 
Questioninternal and internal protected Pin
Sonia Gupta5-Aug-07 22:25
Sonia Gupta5-Aug-07 22:25 
AnswerRe: internal and internal protected Pin
N a v a n e e t h5-Aug-07 22:46
N a v a n e e t h5-Aug-07 22:46 
GeneralRe: internal and internal protected Pin
Sonia Gupta5-Aug-07 23:00
Sonia Gupta5-Aug-07 23:00 
GeneralRe: internal and internal protected Pin
N a v a n e e t h6-Aug-07 1:13
N a v a n e e t h6-Aug-07 1:13 
AnswerRe: internal and internal protected Pin
m@u5-Aug-07 23:41
m@u5-Aug-07 23:41 
Hi
Protected is like a private member for a class, but it's visible in derived classes also.
internal is like public but only inside the current assembly.

so.
if you need a property that can be accessed from other classes inside your assembly and a derived class from another assembly should be able to provide a value for it, you make it
protected internal, which means public inside the current assembly and private for all the other asemblies.

let's say you have 2 assemblies the BaseClassLib and the ConsumerLib

now in the BaseClassLib you have 2 classes called ConsumerClass and ProviderClass

<br />
public class ConsumerClass<br />
{<br />
    public ConsumerClass(ProviderClass Provider)<br />
    {<br />
        // calls the Protected internal function of any ProviderClass-derived class<br />
        Console.WriteLine(Provider.getProtIntVal());<br />
    }<br />
}<br />
public abstract class ProviderClass<br />
{<br />
    protected internal abstract string getProtIntVal();<br />
}<br />


in the ConsumerLib you have a Reference to the ProviderLib and you have 2 classes called StartupClass and DerivedProviderClass

<br />
public class DerivedProviderClass:ProviderClass<br />
{<br />
    public DerivedProviderClass()<br />
    {<br />
    }<br />
    protected override string getProtIntVal()<br />
    {<br />
        return "this is a string";<br />
    }<br />
}<br />
public class StartupClass<br />
{<br />
    [STAThread]<br />
    public static void Main(params string[] args)<br />
    {<br />
        DerivedProviderClass c = new DerivedProviderClass();<br />
        // Next will cause a compiler - Error<br />
        console.WriteLine(c.getProtIntVal());<br />
        // Next will work<br />
        ConsumerClass cons = new ConsumerClass(c);<br />
    }<br />
}<br />


hope this helps
greets
m@u
AnswerRe: internal and internal protected Pin
Hessam Jalali5-Aug-07 23:46
Hessam Jalali5-Aug-07 23:46 
AnswerRe: internal and internal protected Pin
Pete O'Hanlon6-Aug-07 1:34
mvePete O'Hanlon6-Aug-07 1:34 
GeneralRe: internal and internal protected Pin
Sonia Gupta6-Aug-07 1:41
Sonia Gupta6-Aug-07 1:41 
GeneralRe: internal and internal protected Pin
Pete O'Hanlon6-Aug-07 2:42
mvePete O'Hanlon6-Aug-07 2:42 
GeneralRe: internal and internal protected Pin
originSH6-Aug-07 4:03
originSH6-Aug-07 4:03 
QuestionTake over a GUI of running program Pin
Morad Kobi5-Aug-07 22:21
Morad Kobi5-Aug-07 22:21 
AnswerRe: Take over a GUI of running program Pin
Hessam Jalali6-Aug-07 23:17
Hessam Jalali6-Aug-07 23:17 
Questionregarding xml's property dynamically Pin
praveenkumar palla5-Aug-07 21:51
praveenkumar palla5-Aug-07 21:51 
QuestionDataAdapter.Fill() Pin
blackjack21505-Aug-07 21:43
blackjack21505-Aug-07 21:43 
AnswerRe: DataAdapter.Fill() Pin
Marek Grzenkowicz5-Aug-07 22:04
Marek Grzenkowicz5-Aug-07 22:04 
AnswerRe: DataAdapter.Fill() Pin
N a v a n e e t h5-Aug-07 22:49
N a v a n e e t h5-Aug-07 22:49 
AnswerRe: DataAdapter.Fill() Pin
Nouman Bhatti6-Aug-07 2:12
Nouman Bhatti6-Aug-07 2:12 
QuestionFind Out the executed page??? Pin
mimimimilaw5-Aug-07 21:08
mimimimilaw5-Aug-07 21:08 
QuestionCalling unmanaged DLL-methodes (winmm.dll) Pin
J. Holzer5-Aug-07 20:32
J. Holzer5-Aug-07 20:32 
AnswerRe: Calling unmanaged DLL-methodes (winmm.dll) Pin
m@u5-Aug-07 21:29
m@u5-Aug-07 21:29 
AnswerRe: Calling unmanaged DLL-methodes (winmm.dll) Pin
originSH5-Aug-07 21:57
originSH5-Aug-07 21:57 
QuestionODBC how to connect reomte SQL Server Pin
jason_mf5-Aug-07 20:16
jason_mf5-Aug-07 20:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.