Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Open Source Projects > Code Converter > Adding of EventHandler fails to convert properly C#->VB

Not answered Adding of EventHandler fails to convert properly C#->VB

Feed from this thread
  • Posted on Oct 14, 2010 (permalink)

    Hello,

    I was wondering what would be the downside of converting c# event assignments:
    radButton1.Click += radButton1_Click;
    to:
    AddHandler radButton1.Click, AddressOf radButton1_click

    But from VB to C# it is working just fine.... why?

    Lately I've started to use the converter a lot, in order to provide solutions to people in both C# and vb, and because of the fact that the forum does not allow for uploading files I'm creating all the code in the examples by hand.

    It's always a pain having to convert all of the event handlers by hand....

    Best Regards,
    Emanuel Varga

    Reply

  • Posted on Oct 25, 2010 (permalink)

    This is actually a limit of the underlying NRefactory engine that powers the Code Converter. I suggest you request this support on the SharpDevelop forums: http://community.sharpdevelop.net/tags/nrefactory/default.aspx. You can further test the NRefactory engine using the simple converter provided by the core team: http://codeconverter.sharpdevelop.net/SnippetConverter.aspx.

    I'm not entirely sure why the core engine can convert in one direction and not other. If I had to guess, I would say the language shortcut in C# is too ambiguous. That is, "+=" can be used for a number of things in C#, such as concatenating strings or incrementing values, so it's not "guaranteed" to be an event handler. In VB, though, the explicit AddHandler can more reliably be converted.

    Hopefully a solution will be available soon to save you the manual steps! Sorry for the trouble.

    -Todd

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Open Source Projects > Code Converter > Adding of EventHandler fails to convert properly C#->VB