Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there a use for... Pin
BobJanova30-Aug-11 0:20
BobJanova30-Aug-11 0:20 
GeneralRe: Is there a use for... Pin
Narf the Mouse30-Aug-11 0:38
Narf the Mouse30-Aug-11 0:38 
GeneralRe: Is there a use for... Pin
BobJanova30-Aug-11 6:52
BobJanova30-Aug-11 6:52 
AnswerRe: Is there a use for... Pin
GParkings1-Sep-11 7:04
GParkings1-Sep-11 7:04 
GeneralRe: Is there a use for... Pin
Narf the Mouse1-Sep-11 7:16
Narf the Mouse1-Sep-11 7:16 
GeneralRe: Is there a use for... Pin
GParkings1-Sep-11 7:23
GParkings1-Sep-11 7:23 
GeneralRe: Is there a use for... Pin
Narf the Mouse1-Sep-11 8:26
Narf the Mouse1-Sep-11 8:26 
QuestionInheritance Pin
lukeer26-Aug-11 3:47
lukeer26-Aug-11 3:47 
Hello experts,

I have an inheritance issue that can be better explained in code than in text:
C#
public abstract class AbstractBase
{
    protected abstract void DoSomething();
}


public class FirstDerived : AbstractBase
{
    protected override void DoSomething()
    {
        int foo = 5;
    }
}


public class SecondDerived : AbstractBase
{
    protected override void DoSomething()
    {
        int bar = 3;
    }

    private void DoAnotherThing()
    {
        FirstDerived firstDerived = new FirstDerived();
        firstDerived.DoSomething();  // Here is the error
    }
}

The mentioned error in German reads
Auf den geschützten Member "AbstractBase.DoSomething()" kann nicht über einen Qualifizierer vom Typ "FirstDerived" zugegriffen werden. Der Qualifizierer muss vom Typ "SecondDerived" (oder von ihm abgeleitet) sein.

In English that would mean something like
A qualifier of type "FirstDerived" cannot access the protected member "AbstractBase.DoSomething()". The qualifier has to be of type "SecondDerived" (or derived thereof).

Why would that be?
Do I have to change from protected to internal?

Ciao,


luker

AnswerRe: Inheritance Pin
Rob Philpott26-Aug-11 3:55
Rob Philpott26-Aug-11 3:55 
AnswerRe: Inheritance Pin
MicroVirus26-Aug-11 4:17
MicroVirus26-Aug-11 4:17 
GeneralMessage Removed Pin
26-Aug-11 5:40
mentorNot Active26-Aug-11 5:40 
GeneralRe: Inheritance Pin
MicroVirus26-Aug-11 6:09
MicroVirus26-Aug-11 6:09 
GeneralMessage Removed Pin
26-Aug-11 7:10
mentorNot Active26-Aug-11 7:10 
GeneralRe: Inheritance Pin
jschell26-Aug-11 8:36
jschell26-Aug-11 8:36 
GeneralRe: Inheritance Pin
MicroVirus26-Aug-11 14:05
MicroVirus26-Aug-11 14:05 
GeneralMessage Removed Pin
26-Aug-11 15:00
mentorNot Active26-Aug-11 15:00 
GeneralRe: Inheritance Pin
Anna-Jayne Metcalfe27-Aug-11 0:04
Anna-Jayne Metcalfe27-Aug-11 0:04 
GeneralRe: Inheritance Pin
Hans Dietrich27-Aug-11 6:04
mentorHans Dietrich27-Aug-11 6:04 
GeneralRe: Inheritance Pin
Anna-Jayne Metcalfe27-Aug-11 6:17
Anna-Jayne Metcalfe27-Aug-11 6:17 
GeneralRe: Inheritance Pin
MicroVirus27-Aug-11 8:46
MicroVirus27-Aug-11 8:46 
GeneralRe: Inheritance Pin
MicroVirus27-Aug-11 2:41
MicroVirus27-Aug-11 2:41 
GeneralRe: Inheritance Pin
lukeer27-Aug-11 3:33
lukeer27-Aug-11 3:33 
GeneralRe: Inheritance Pin
lukeer27-Aug-11 3:21
lukeer27-Aug-11 3:21 
GeneralRe: Inheritance Pin
lukeer27-Aug-11 3:19
lukeer27-Aug-11 3:19 
GeneralRe: Inheritance Pin
MicroVirus27-Aug-11 5:40
MicroVirus27-Aug-11 5:40 

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.