What is a delegate?

A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

Showing Answers 1 - 3 of 3 Answers

swag

  • Dec 24th, 2005
 

A delegate is a type safe where method to be invoked is determined at run time.it calls the method by their address in stead of their name.

  Was this answer useful?  Yes

learner22

  • Jun 20th, 2008
 

A delegate in C# is simlilar to function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object.
The delegate object can then be passed to code which can call the referenced method,with out having to know at compile time which method will be invoked. It doesn't know  or care about the class of the object that references. All that matters is that the methods argument types and return type match the delegate.

  Was this answer useful?  Yes

skurt000

  • Jul 11th, 2008
 

A typical example of delegate usage can be found in event handling. For example, when the event is raised that the selected index of a dropdown list changed, we want method "ddlFoo_SelectedIndexChanged(object sender, EventArgs e)" to be called.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions