Jump to content
  • Advertisement
Sign in to follow this  
Xeno

[.net] Overriding Clear() in CollectionBase

This topic is 5173 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!