|
-
Nov 22nd, 2004, 02:11 AM
#1
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:
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,
-
Nov 22nd, 2004, 09:01 AM
#2
I wonder how many charact
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|