What are "Delegates" in C# - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Sunday, November 20, 2011

What are "Delegates" in C#

Delegates, a word that frequently pops up in the Interviews and many candidates gets confused and nervous when they hear this word. In this article, I am trying to explain delegates in easy to understand way, hopefully after going through this article, you will feel comfortable using delegates and answering any question related with delegates.

What is a delegate?


Delegate is an object that can refer to a method.

When we are creating delegates, we are creating an object that can hold a reference to a method; it necessarily means that a delegate can invoke the method to which it refers. 

As the delegate refers to a method, the same delegates can be used to call multiple methods just by changing the method name at the run time; provided the method (instance or static) match the signature and return type.

Confused? not a problem, just go through below code snippet of code behind (DelegatesPage 
.aspx.cs) of my DelegatesPage.aspx page.

No comments:

Post a Comment