Shared(Static) classes with events in C#

Posted by diamandiev on Stack Overflow See other posts from Stack Overflow or by diamandiev
Published on 2010-03-27T07:49:48Z Indexed on 2010/03/27 7:53 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

Here is an example of what i would do in vb:

Public Class Class1
    Public Shared WithEvents Something As New EventClass

    Public Shared Sub DoStuff() Handles Something.Test

    End Sub
End Class

Public Class EventClass
    Public Event Test()
End Class

Now how do i do this in c#. I know there is not handles clause in c# so i need some function that is called and assign the event handlers there. However since its a shared class there is no constructor i must put it somewhere outside of a function.

Any ideas?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb