Here is an example of what I would do in Visual Basic:
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
How do I do this in C#?
I know there is not a Handles clause in C# so I need some function that is called and assign the event handlers there. However, since it’s a shared class, there is no constructor; I must put it somewhere outside of a function.
How can it be achieved?
You can use the static constructor…