What is delegates with example code in c# .net
What is delegates with example code in c# .net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 18, 2012, 12:09 AM
Hi,
Delegates in the C# language are objects that reference a certain behavior.A delegate in C# is similar to a 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, without having to know at compile time which method will be invoked. Unlike function pointers in C or C++, delegates are object-oriented, type-safe, and secure.
Please refer
http://www.codeproject.com/Articles/11657/Understanding-Delegates-in-C
http://www.codeproject.com/Articles/71154/C-Delegates-101-A-Practical-Example
hope this will help you.
VulpesPosted Jul 17, 2012, 2:00 PM
Delegates are analogous to function pointers in unmanaged languages such as C++.
It's possible for a single delegate to represent multiple methods using a process known as 'multi-casting'.
For an example of using delegates, check out this thread:
http://www.c-sharpcorner.com/Forums/Thread/179484/benefits-of-delegate-with-example.aspx