First of all I just want you let you all know that this question is coming from a newbie so don't be too harsh on me.
As far as I know, in VB.net when you want a function or sub to be raised by an event all you have to do is add "Handles NameofTheEvent" at the end of it. Like this:
Public Sub Action1() Handles MyEvent
Public Sub Action2() Handles MyEvent
public delegate void MyDelegate();
public static event MyDelegate MyEvent = new MyDelegate(Action1) + new MyDelegate(Action2);
public void Action1()
public void Action2()
None of them is significantly better than the other one. They are different languages with different syntax, which, by the way can be converted from one into the other, so under the hood there should not really be many differences.
+ operator between delegates in C# is concatenating delegates. To put it into simple words, it means that
Action2 should be executed when the event is triggered. In VB you are writing the same more verbosely.
If we have to choose, I would choose C#, but not because its event handling. My reasons would be that:
But these are my subjective preferences.
@Pieter Witvoet's contribution is:
If you don't like custom delegates in C# then you can use
Func<>(you lose the ability to give arguments meaningful names, though). If you want to register or unregister an event handler at any time you can use the