覆盖和覆盖方法必须具有相同的可访问性,那么为什么不是Page.CreateChildControls同真()?不是、方法、CreateChildControls、Page

2023-09-07 08:43:46 作者:久念成瘾

方法虚拟可以在派生类中重写。其中的一个限制是,覆盖和覆盖方法必须具有相同的可访问性。因此,如果虚方法被标记为受保护的内部,然后覆盖的方法也必须标记为受保护的内部(它不能是例如标记为刚保护)。

Methods marked as virtual can be overridden in derived classes. One of the restrictions is that overriding and overridden methods must have same accessibility. Thus, if virtual method is marked as protected internal, then overriding method must also be marked as protected internal (it cannot be for example marked as just protected).

由于类重写 Control.CreateChildControls(),其中被标记为保护内部,然后 Page.CreateChildControls()也应该标记为受保护的内部,但而是被标记为保护。这怎么可能?

Since Page class overrides Control.CreateChildControls(), which is marked as protected internal, then Page.CreateChildControls() should also be marked as protected internal, but instead is marked as protected. How is that possible?

推荐答案

我可能没有得到正确你的问题。这是我发现在MSDN的 Control.CreateChildControls

I probably did not get your question right. This is what i found at MSDN for Control.CreateChildControls

protected internal virtual void CreateChildControls()