Reputation: 1998
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
).
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?
Upvotes: 1
Views: 523
Reputation: 63445
Could it be you were looking at this incorrect example on MSDN:
protected override void CreateChildControls()
{
// Creates a new ControlCollection.
this.CreateControlCollection();
// Create child controls.
ChildControl firstControl = new ChildControl();
firstControl.Message = "FirstChildControl";
ChildControl secondControl = new ChildControl();
secondControl.Message = "SecondChildControl";
Controls.Add(firstControl);
Controls.Add(secondControl);
// Prevent child controls from being created again.
ChildControlsCreated = true;
}
Source: http://msdn.microsoft.com/en-us/library/system.web.ui.control.createcontrolcollection.aspx
Upvotes: 1
Reputation: 21928
I probably did not get your question right. This is what i found at MSDN for Control.CreateChildControls
protected internal virtual void CreateChildControls()
Upvotes: 2