Convert an interface's event from VB.Net to C#

Posted by Jules on Stack Overflow See other posts from Stack Overflow or by Jules
Published on 2010-03-24T10:01:53Z Indexed on 2010/03/24 10:03 UTC
Read the original article Hit count: 196

Filed under:
|
|
|

Hi, I'm struggling to convert the below code to C#.

Class Class1
    Implements IMyInterface

    Public Event MyEvent(ByVal sender As Object, ByVal e As MyEventArgs) Implements IMyInterface.MyEvent

    Public Sub New()
        AddHandler Me.Slider.ValueChanged, AddressOf OnSliderValueChanged
    End Sub

    Private Sub OnSliderValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent MyEvent(Me, New MyEventArgs())
    End Sub

End Class

Here's what visual studio inserts when I ask it to implement for me:

event EventHandler<MyEventArgs> IMyInterface.MyEvent
    {
        add { throw new NotImplementedException(); }
        remove { throw new NotImplementedException(); }
    }

With a bit of googling I'm sure I can find out what to replace the NotImplementedException parts with but VS is still telling me that the definition is not implemented anyway.

© Stack Overflow or respective owner

Related posts about events

Related posts about interface