Results 1 to 2 of 2

Thread: Questions on Delegate

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Question Questions on Delegate

    Take a look at this URL, where I was reading up on Delegates from:

    http://abstractvb.com/code.asp?A=1084


    In the example given, there exists a procedure,

    VB Code:
    1. c.NotifyOnAddressChange(New Customer.AddressChanged(AddressOf AddressModified))

    This of course, delegates the AddressChange event to a sub named AddressModified.

    Now, if I didn't use delegates, I could have simply used AddHandler and given the AddressOf the same sub.

    Even after reading that article, I'm a little unclear as to what advantages Delegates have over plain ol' Events.

    Perhaps someone could explain in their own words?

    Tx,

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I don't really know to tell you the truth. Addhandler and RemoveHandler basically hide the details and create delegates for you at compile time. Perhaps its best to use delegates in case some C# programmers have to look at your code down the road... I don't know. I found this tidbit of a group forum:

    "In VB.NET for the same purpose it can be used but its not mandatory to have delegate to use the events becoz we have raiseevent, withevents and addhandler statements to handle events. But if u r declaring an event in base class & would like to raise thro derived class then it is possible thro delegates."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width