Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
What is the use of delegate in .NET Framework?
December 03, 2009
What is the use of delegate n .NET Framework? I am bit confused with this concept.
it would be better to have an example in C# because i am confirtable in C#
Thanks In Advance
Posted Date: December 04, 2009 Points: 5
Callback functions are certainly one of the most useful programming mechanisms ever created. The C runtime's qsort function takes a callback function to sort elements within an array. In Windows, callback functions are required for window procedures, hook procedures, asynchronous procedure calls, and more. In the Microsoft .NET Framework, callback methods are used for a whole slew of things. You can register callback methods to get assembly load/unload notifications, unhandled exception notifications, database/window state change notifications, file system change notifications, menu item selections, completed asynchronous operation notifications, filtering a set of items, and so on.
you can find mire information here
Mark As Answer
" if this post help you.
Posted Date: December 13, 2009 Points: 5
A "delegate" is a type-safe object that points to another method in the application,which can be invoked at later time.More specifically a delegate type contains three important information,
1. The name of the method on which it makes calls.
2. The arguments o this method.
3. The return value of the method.
Once a delegate has been created and provided the required information, it may be dynamically invoke the methods it pointed to at runtime. Every .NET delegate is automatically endowed with the ability to call their methods synchronously or asynchronously.
For more detail refer to the following article,
Posted Date: February 26, 2010 Points: 5
What is a Delegate?
When we talk about delegates in .NET then one thing that comes to our mind is what delegate means to a novice developer
. In simple words we can say delegates are a .NET object which points to a method that matches its specific signature.
In other words delegates are function pointers that point to function of matching signatures. Function pointers which are extensively used in c/c++ to points to a function holds only the memory address of the function, it doesn't carry further information about the function parameters, return type etc. On the other hand .NET framework has introduced a type-safe mechanism called delegates, with automatic verification of the signature by the compiler.
So comparatively delegates add a safety dimension in handling function pointers in .NET.
Posted Date: July 13, 2011 Points: 20
[URL=http://www.cegonsoft.com/jobassistanceprogram.php]Delegates[/URL] are very similar to 'pointers to functions' in C and C++
First we create a delegate, then we can assign any function that has a similar prototype of the one which we have specified with the delegate.
public delegate int Dlg(int x, int y); //where Dlg is the name of Delegate
when we need to create a 'Delegate object' (i.e. a pointer to a function which has a specified prototype)
Dlg d1=new Dlg(function_name); //if the class is in some other class use 'class_name.function_name'
function_name->has to be the name of a function which receives two integers as arguments and return an integer
int res=d1(20, 20);
Applications of Delegates
used in event handling in C#.NET
i.e. we assign different event handler function to events like Click etc. Every event has a delegate object to represent its handler function.When we assign a function to an event handler, it is actually assigned to the corresponding delegate object and are invoked like in the above example.
To post reply
Related Questions Related Questions
What is a framework?
Doubt on features of .NET Framework
.net framework 3.5 in windows server 2000
ASP.NET - Learning .NET Framework 3.0 / 3.5
ASP.NET Application - DAL Framework
Latest .NET Framework Certification
Latest Forum Questions From The Same Category
Window Service C#.net not working properly
C# Onvif IP Camera Viewer NuGet package
Land Registry Business Gateway Webservice - reference the returned XMLDocument
Technology to be used for Finance Application
problem instal net framwork 4
I am looking for Dotnet developer opening in Middle level company.
Validate the Grade in gridview in asp.net using C#
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend