Groups | Blog | Home
all groups > c# > april 2004 >

c# : Why the function need to run by the delegate?


oops
4/16/2004 9:31:06 AM
hello,

Hope by now you knew how to use delegates, now question is why and when? Its more relevant to library developers, think of a scenario where you want that implementation of your function ABC() could be provided by any developer consuming your library but you don't want to impose name restrictions on it. Delegates provide an elegant method to register signature of to be implemented method and calling these methods without having type information from called assembly beforehand.

William Ryan eMVP
4/16/2004 4:14:16 PM
You already use delegates all the time when you deal with events in .NET
classes. If you had a bankAccount class and wanted to implement an
AccountOverdrawn event for instance whenever X happens, you'd raise an event
in the get/set accessor and use a delegate as the event handler.
[quoted text, click to view]

Jet Leung
4/16/2004 10:56:24 PM
Hi:
I had asked how to use delegate in the programming. And now actually I want
to know why and when the function need to run by the delegate?

AddThis Social Bookmark Button