.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum


Posted By: DPK     Posted Date: September 21, 2008    Points:2   Category :ASP.Net
hello friend...

Delegate is completely going over my HEAD....

pls anyone can make me understand this theory by any other way and pls it will be more better for me if u could give any programe example:
A delegate is a simple class that is used to point to methods with a specific signature, becoming essentially a type-safe function pointer. A delegate's purpose is to facilitate a call back to another method (or methods), after one has been completed, in a structured way.

Pretend you have Class A that performs a process when its method DoTask is called. Your ASPX page creates an instance of that class and calls DoTask. When the task is completed, you want your ASPX page to call another method from another class. At the same time you also want to make sure that any class's method (an instance or a static method) can be run after DoTask, without having DoTask know anything about the class or its method. As long as the method conforms to a specific signature, it should be run.

Author: Amit Mehra             
Posted Date: September 21, 2008     Points: 5   

See this example will help you to understand the Delegate..


Please "Mark As Answer " if this post help you.
Author: DPK             
Posted Date: September 24, 2008     Points: 5   

Thanks Amit to reply but I know that how to use Delegate and all its flow, my confusion is what to take that why to use delegate...what is that I cant do without Delegate? what is requirement to use Delegate...

Hope you got what i wanted to ask now..


Author: TotalDotNet             
Posted Date: August 16, 2010     Points: 5   


A delegate is like a reference to a method. Once a delegate object, encapsulate a reference to a method inside it, the delegate can be called like the method, with same parameters and return-Type. Similar to function pointer in C or C++, A delegate in C# is used as reference to a method.

The delegates are used where we just know the signature of method, The name of the method remain unknown and needs to be invoked at runtime. Hence the method, is passed as a parameter to a delegate, The delegate can be called like the normal method. The features of delegates are as follows:

* Delegates are type safe, unlike pointer in c or c++.
* Delegates allow methods to be passed as parameters.
* Multiple methods can be called on a single event, By chainning the Delegates together.

for more info


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend