Geeks With Blogs


Add to Google

Tim Hibbard CEO for EnGraph software

It is so much easier to create, raise and handle events in than C#.  In VB, it is simple: 
Public Event MyEvent()
RaiseEvent MyEvent()
Private Sub MyEventHandler() Handles MyObject.MyEvent

In C#, I have delegates and protected voids all over the place!  Thankfully, VS takes care of the code creation for handling the events, otherwise I would pull my hair out trying to match method signatures.

I'm sure there is a good reason for making this so difficult.  I know that it is possible to fire events over remoting channels in C#.  Maybe Dusty will be nice enough to educate me like he did on my last C# question.

For my own personal bookmarking purposes, this is where I read how to implement C# event handling.  If there is a better source, please let me know.

Posted on Tuesday, November 28, 2006 3:01 PM .NET , Remoting | Back to top

Comments on this post: Events are easier in VB

# re: Events are easier in VB
Requesting Gravatar...
The delegate syntax allows for multiple functions to handle the same function, as well as handling for events to be changed dynamically at run time, as well as handling events for dynamically created controls.

VB also supports the same syntax, but the default is the old VB style syntax.

You shouldnt ever have a problem matching method signatures, Visual studio will autocomplete everything for you as soon as you get to the += part of the line.
Left by Jason Coyne on Nov 28, 2006 4:12 PM

# re: Events are easier in VB
Requesting Gravatar...
+= saved my life. No joke :)
Left by Tim Hibbard on Nov 29, 2006 9:32 AM

# re: Events are easier in VB
Requesting Gravatar...
C# also lets you override the Event add and remove bits

public event EventHandler Click
add {}
remove {}

Which can be nice.
Left by Dru on Nov 29, 2006 11:27 AM

Your comment:
 (will show your gravatar)

Copyright © Tim Hibbard | Powered by: