What is the use of delegate

Posted by Ray.chayan under C# on 6/25/2010 | Views : 28331 | Status : [Member] | Replies : 10
I have studied lots of books and materials on internet but I can never understand what is the use of delegate in development. Actually I want to know in what particular situation a developer should use delegate in code. Please provide me some example.




Responses

Posted by: Raja on: 6/25/2010 [Member] Starter

Up
0
Down
As you already know what is delegates, so I would point to the resources which tell you where to use.
Watch this
http://www.dotnetfunda.com/tutorials/videos/x67-delegates-and-events-.aspx
If not read this
http://www.dotnetfunda.com/articles/article97.aspx
or
http://www.dotnetfunda.com/articles/article201.aspx

Thank you

Regards,
Raja, USA

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: BangaruBabu on: 6/27/2010 [Member] Starter

Up
0
Down
In order to create customized event handlers ,we use delegates

http://www.csharphelp.com/2006/12/delegates-and-event-handling-in-c/

BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santoshkumar on: 6/29/2010 [Member] Starter

Up
0
Down
Delegate is used to represent one or more functions.
It is not a member of a class, but similar to a class.
To consume any delegate, we need to create an object to delegate.
It is type that references a method.
Delegates are the backbone for events.
Delegate method can be invoked like any other method with parameters and written value.
Types of delegates.
Single cast delegate: it represent one function.
multi cast delegate: it represent more than one function.

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 7/29/2010 [Member] Bronze

Up
0
Down
You will get better Idea from the link-

http://msdn.microsoft.com/en-us/library/aa288459(VS.71).aspx

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Esensahoo on: 1/2/2011 [Member] Starter | Points: 25

Up
0
Down
I have created a sample program showing a real time use of delegate.I hope this article may help you understand the use of delegate.Below is the URL.

http://www.dotnetfunda.com/articles/article1107-practical-use-of-delegate-in-real-time-application-1-.aspx

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/5/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Below link explains in detail about delegate

http://www.aspfree.com/c/a/C-Sharp/C-Sharp-Delegates-Explained/

Thanks
Karthik
www.f5Debug.net

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 7/15/2011 [Member] [MVP] Bronze | Points: 25
Posted by: Lakn2 on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
Refer this

http://stackoverflow.com/questions/191153/when-would-you-use-delegates-in-c

Thanks&Regards
LakshmiNarayana Nalluri.

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pravesh Singh on: 5/22/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

When we make an object of a class then we can access all function of a class and Base class functions too. Here we can see that a user can simple make an object of a class and access all information of class. But in real word this is drawback of an object...

Read full content from following article, I hope it's helpful for you.

http://mindstick.com/Articles/2ace6310-943e-4f1b-a193-c1b5f61acd54/default.aspx?Delegate+in+C+Net

Pravesh Singh

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rampatter on: 2/16/2015 [Member] Starter | Points: 25

Up
0
Down
In the .NET environment, a delegate is a type that defines a method signature and it can pass a function as a parameter. In simple words we can say delegate is a .NET object which points to a method that matches its specific signature. A delegate is a form of type-safe function pointer used by the Common Language Infrastructure.

More about .Net Delegate....

http://net-informations.com/faq/net/delegates.htm

Rampatter

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response