abstract events

axnst2
axnst2 used Ask the Experts™
on
Hi Experts,

When I try to compile the attached code, I get the following errors:

<'CMyClass' does not implement inherited abstract member 'CMyBaseClass.ErrorEvent.add'>

Also, when I go to add the "ErrorEvent" event in CMyClass, the event doesn't come up on the list of available events.

Any ideas?


abstract class CMyBaseClass
{
    protected delegate void ErrorEventDelegate(string error);
    protected abstract event ErrorEventDelegate ErrorEvent;
}

class CMyClass : CMyBaseClass
{
    public CMyClass()
    {
        base.ErrorEvent += new ErrorEventDelegate(CMyClass_ErrorEvent);
     }

    void CMyClass_ErrorEvent(string error)
    {
        throw new Exception("The method or operation is not implemented.");
    }
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
not sure why you have an abstract event... but you need to override that in your class like this..

 protected override event CMyBaseClass.ErrorEventDelegate ErrorEvent;

-Ajitha
axnst2IT Manager

Author

Commented:
I have an abstract event so that the inhereted class is forced to have to subscribe to/implemnt it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial