GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 85 of 436    Print  
What is a delegate?
A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.


  
Total Answers and Comments: 3 Last Update: July 11, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
December 24, 2005 04:54:48   #1  
swag Member Since: December 2005   Contribution: 18    

RE: What is a delegate?
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.
 
Is this answer useful? Yes | No
June 20, 2008 10:34:02   #2  
learner22 Member Since: March 2008   Contribution: 3    

RE: What is a delegate?
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.

 
Is this answer useful? Yes | No
July 11, 2008 16:12:22   #3  
skurt000 Member Since: July 2008   Contribution: 1    

RE: What is a delegate?

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.


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape