Introduction

Delegate is like a buzz word in C#.NET programming. In this article, I explain delegates, multicast delegates and their usage with the help of simple C# programs.

What is a Delegate?

Delegate is a type which holds the method(s) reference in an object. It is also referred to as a type safe function pointer.

Advantages

Encapsulating the method's call from caller

Effective use of delegate improves the performance of application

Used to call a method asynchronously

Declaration

public delegate type_of_delegate delegate_name()

Example:

publicdelegateint mydelegate(int delvar1,int delvar2)

Note

You can use delegates without parameters or with parameter list

You should follow the same syntax as in the method (If you are referring to the method with two int parameters and int return type, the delegate which you are declaring should be in the same format. This is why it is referred to as type safe function pointer.)

It's a nice article
But this statement is wrong that "Multicast delegates must contain only methods that return void, else there is a run-time exception". I tested with int return type that working.
See the following code