Questin on Delgates

  • Thread starter Thread starter jw56578
  • Start date Start date
J

jw56578

I've read a basic tutorial on delegates but am still unclear about
them. Can someone explain what the point of using them is. I don't
completely understand them yet nor the reason for their use.
Thanks
 
They're very commonly used with GUI events. i.e. When the user clicks a
button, the button automatically fires a Click event. If you want code to
respond to that Click event, you have to be able to notify the button to
call your method with that code when the Click event occurs. This is where
the delegate comes in - it provides the mechanism to tell the Click event to
call your method. So, you will define a delegate that refers to your method
and hook it up to the button's click event. Every time a user interacts
with some control in your GUI, an event will fire and any methods that have
been hooked up to that event, via a delegate, will be called.

Joe
 
Back
Top