本文介绍了覆盖和覆盖方法必须具有相同的可访问性,那么为什么不是Page.CreateChildControls同真()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 forControl.CreateChildControls

protected internal virtual void CreateChildControls()

这篇关于覆盖和覆盖方法必须具有相同的可访问性,那么为什么不是Page.CreateChildControls同真()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 09:17