Final Form
Final Form

Reputation: 318

C# protected method accessed by derived class

Can a derived class access it's base class's protected method with base.method()?

Like the following:

Class A
{   
  Protected doThis()   
}

Class B : A   
{   
  base.doThis();   
}

Upvotes: 0

Views: 4956

Answers (2)

Floremin
Floremin

Reputation: 4089

That is the definition of access modifier "protected":

http://msdn.microsoft.com/en-us/library/bcd5672a(v=vs.110).aspx

http://msdn.microsoft.com/en-us/library/ba0a1yw2.aspx

Upvotes: 0

Keith Nicholas
Keith Nicholas

Reputation: 44288

you can just do doThis() in a method in the class

assuming you mean this :-

class A
{
    protected void doThis()
    {

    }
}

class B : A
{
    public void MyMethod()
    {
         doThis();
    }
}

Upvotes: 4

Related Questions