Where to register for C# events?

Posted by themaninthesuitcase on Stack Overflow See other posts from Stack Overflow or by themaninthesuitcase
Published on 2010-03-15T15:05:07Z Indexed on 2010/03/15 15:09 UTC
Read the original article Hit count: 169

Filed under:
|

I am currently transitioning from VB to C# and am having some issues with regards to registering my interest in an event.

When using VB it was simply a case of specifying that a method Handles and event, often this was generated by using the object events list. While I can easily use the Class.event += delegate in C# I am unsure where the best place is to place the code to do this.

Am I best placing it inside of the InitializeComponent() as per the generated code (say if you select the event in the from designer) or should I place it inside the constructor for better readability/maintenance. If inside the constructor, should it be before or after the call to InitializeComponent()?

© Stack Overflow or respective owner

Related posts about c#

Related posts about events