Possible Duplicates:
When would you use delegates in C#?
The purpose of delegates
Delegates, Why?
What are the advantages of delegates?
What are Delegates in c# and why are they used?
Thanks,
Pradeep
Possible Duplicates:
When would you use delegates in C#?
The purpose of delegates
Delegates, Why?
What are the advantages of delegates?
What are Delegates in c# and why are they used?
Thanks,
Pradeep
Delegates are essentially method pointers; they are used to call a method from a location unknown at compile-time. For example, they can be used by events (every time you add an eventhandler, what you're really doing is adding a delegate to your handler to a collection of handlers to be notified when the event is raised.
A delegate is a kind of type that can refer to a method (instance or static). If you are familiar with function pointers in C++, they are conceptually similar.
Since they are a type, an instance of a delegate type can be created and assigned to a method at runtime, this allows you to implement things like callbacks and events.