override and internal

  • Thread starter Thread starter Jeremy Chapman
  • Start date Start date
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?
 
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
 
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();
}
}
 
Back
Top