How do you override a protected method?
Posted: Wed Feb 13, 2008 10:05 am
I'm trying to implement the disposable pattern on a form by overriding the base form dispose method.
I get this warning: "TestForm.Dispose(bool)" hides inherited member "System.Windows.Forms.Form.Dispose(bool)". To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
If I uncomment the 'is override', I get this error: "TestForm.Dispose(bool)": cannot change access modifiers when overriding "protected" inherited member "System.ComponentModel.Component.Dispose(bool)"
- Code: Select all
var _components as IContainer?
def dispose(disposing as bool) #is override
if disposing and _components
_components.dispose
base.dispose(disposing)
I get this warning: "TestForm.Dispose(bool)" hides inherited member "System.Windows.Forms.Form.Dispose(bool)". To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
If I uncomment the 'is override', I get this error: "TestForm.Dispose(bool)": cannot change access modifiers when overriding "protected" inherited member "System.ComponentModel.Component.Dispose(bool)"