|
-
Jul 2nd, 2007, 03:42 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2.0] Delegates and Events
OK, having mucked around with VB.NET for a while, I have decided to have a muck around with C# (2005 Express). So far not too bad, getting used to the syntax etc, but I am currently banging my head against the brick wall called 'Delegates and Events'.
Have read articles on MSDN and elsewhere my head is spinning a bit.
As far as I can work out, a delegate is some sort of class or container that can contain references to methods. (Yes?)
So, when you 'wire-up' an event, you pass in the method you want to call when the event fires like so:
Code:
obj.MyEvent += new MyEventHandler(MyMethod); // where MyEventHandler is the delegate
Is the '+=' basically adding MyMethod to a list of methods that is automatically called when the event fires?
Am I close, or miles away with my take on this? 
Thanks for helping out a C# newbie!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|