What is delegates with example code in c# .net
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 17, 2012, 10:00 AM EDT
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 17, 2012, 8:09 PM EDT
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.