469,950 Members | 2,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Implementing an interface and handling an event with the same method

Hi All

I have a class (aClass, derived from aBaseClass) with implements an
interface IMyInterface. aClass also has a private member of type
aNotherClass which raises various events. I would like a specific
method within aClass to handle the event raised by the object of type
aNotherClass AS WELL as implementing the method of the interface.
Unfortunately, the method I've used (outlined below) causes a compiler
error. Is there anyway to get the functionality I'm looking for? I've
considered implementing the interface using the method and using
AddHandler etc... to tie the method to the event, but that seems a bit
clumsy, especially as aNotherClass in reality has a whole bunch of
events that I would like to use.

Public Class aNotherClass
Public Event RaisedEvent()
End Class

Public Interface IMyInterface
Sub RaisedEvent
End Interface

Public Class aClass
Inherits aBaseClass
Implements IMyInterface
Private Withevents _aNotherClass as aNotherClass

Private Sub HandlesEvent() Implements IMyInterface.RaisedEvent
Handles aNotherClass.RaisedEvent()
End Sub

End Class



Oct 25 '06 #1
0 915

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Martyn Lawson | last post: by
8 posts views Thread by Ash | last post: by
2 posts views Thread by cppaddict | last post: by
4 posts views Thread by Frank J. Reashore | last post: by
4 posts views Thread by Mohamed Mansour | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.