Delegate In-Depth

Page history last edited by Rafe 1 yr ago

The MCTS 70-536 book's section on delegates is weak. I had to read several articles online to really get a grip on this topic. Here are a few links to help:

 

Mitchel Sellers (dotnetnuke extraordinaire) wrote a nice write-up on how to create custom events and delegates. Two things I appreciated from this article are:

  1. "A delegate serves as a special event handler, identifying the signature of our event. This ensures that ALL handlers of the event will have all desired event information."
  2. "In this statement you will notice that we check to ensure that CriticalError is not equal to null. This simply ensures that we have at least one subscriber to the method. If we have no subscribers it is not necessary to raise the event." I have been wondering why an event would be equal to null... I run into this a lot, and the reason is very simple: no objects are subscribed to the event.

The article can be found here: http://www.c-sharpcorner.com/UploadFile/mitchel.sellers/CustomEventsAndDelegatesOverview11202006094351AM/CustomEventsAndDelegatesOverview.aspx

 

Comments (0)

You don't have permission to comment on this page.