Delegate in C#



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


  • Encapsulating the method’s call from caller.
  • Effective use of Delegat improves the performance of application.
  • Used to call a method asynchronously.


public delegate type_of_delegate delegate_name()

Example : public delegate int mydelegate(int delvar1,int delvar2)


  • you can use delegeate without parameter or with parameter list.
  • you should follow the same syntax as in the method.

(if you are reffering the method with two int parameters and int return type the delegate which you are declaring should be the same format.This is how it is reffered as type safe function pointer)

Sample Program using Delegate :

public delegate double Delegate_Prod(int a,int b);

class Class1 {

  static double fn_Prodvalues(int val1,int val2)       {      return val1*val2;       }   static void Main(string[] args)   {   


View original post 350 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s