Sign in to follow this  

[.net] Overriding Clear() in CollectionBase

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how come i cant override the public virtual method 'Clear()' of the System.Collections.CollectionBase class? when im trying to override it im getting that error: "C:\Documents and Settings\Roy\My Documents\Visual Studio Projects\WebEngine\Class1.cs(49): 'Goblineye.Projects.WebEngine.EditorCollection.Clear()' : cannot override inherited member 'System.Collections.CollectionBase.Clear()' because it is not marked virtual, abstract, or override" however, the method does declared as virtual... here's the method declaration (provided by MSDN): public virtual void Clear(); i would be grateful for any help.

Share this post


Link to post
Share on other sites
Looks like a doc bug. It's not virtual.

However the implementation looks like this:

public void Clear()
{
this.OnClear();
this.InnerList.Clear();
this.OnClearComplete();
}

OnClear and OnClearComplete are protected virtual, so the idea is that you override these methods.

HTH.

Share this post


Link to post
Share on other sites

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this