I want to override an overridable method in some base class from my
class. It works fine if I manually code the method (as one would
expect), but I want the IDE to auto-generate the template code for me
so I don't have to type all of it in. I'm sure this is possible.
Apparently you can do it from the class designer somehow by openning
the class designer, drilling up through the inheritence heirarchy,
choosing the method ( eg. OnPaint(..) ) and then right-clicking on it
and select Add->Override. But when I right-click I don't get the
'Override' option.
I know from the editor, you can start to type the keywords: 'Protected
Overrides' and then the IDE will kick-in with the avaliable selection.
Here you can scroll down the list and hit ENTER on the method you
want. This works fine-and-dandy, but is there another way?
Thanks,
Jack.
Bryan Phillips - 30 Apr 2007 05:47 GMT
If the base class is abstract, the IDE will automatically generate the
base class's abstract methods in the sub class as soon as you inherit
from the base class. It works the same way as implementing interfaces.
Example:
public abstract class BaseClass { // abstract is required to have
abstract members
public virtual int SomeMethod() { // virtual is required if you
want the subclass to be able to // override this too
return 0;
}
public abstract int SomeOtherMethod(); // subclass must
implement this method
}
--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
Web Site: http://www.composablesystems.net
> I want to override an overridable method in some base class from my
> class. It works fine if I manually code the method (as one would
[quoted text clipped - 14 lines]
> Thanks,
> Jack.