override and internal

J

Jeremy Chapman

In a base class, a method is declared protected internal virtual object
SaveViewState();

I can override it protected virtual object SaveViewState(); but I can not
add the internal keyword. Why not?
 
V

Vadym Stetsyak

Hello, Jeremy!

JC> In a base class, a method is declared protected internal virtual object
JC> SaveViewState();

JC> I can override it protected virtual object SaveViewState(); but I can
JC> not add the internal keyword. Why not?

Compiles fine, on .NET 2.0 VS2005

class A {
protected internal virtual object SaveViewState()
{
return null;
}

}

class B : A {
protected internal override object SaveViewState()
{
return base.SaveViewState();
}
}
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
J

Jeremy Chapman

That's wierd. I get the following error:

Error 1 'Custom.Web.UI.WebControls.MyStyle.SaveViewState()': cannot change
access modifiers when overriding 'protected' inherited member
'System.Web.UI.WebControls.Style.SaveViewState()' C:\Develop\2.0\Class
Libraries\Web.UI.WebControls\MyTest\MyStyle.cs 32 48
Custom.Web.UI.WebControls.MyStyle

public class MyStyle : Style
{
public MyStyle(): base()
{
}

public MyStyle(StateBag bag) : base(bag)
{
}

protected internal override object SaveViewState()
{
return base.SaveViewState();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top