1.
InBlock.gif using System;
InBlock.gif using System.Collections.Generic;
InBlock.gif using System.Text;
InBlock.gif using System.Windows.Forms;
InBlock.gif
InBlock.gif namespace DelegateDemo
InBlock.gif{
InBlock.gif   public class DelegateClass
InBlock.gif    {
InBlock.gif         //public static int Add(int x,int y)
InBlock.gif         //{
InBlock.gif         //    return x + y;
InBlock.gif         //}
InBlock.gif         //public static int Multiply(int x,int y)
InBlock.gif         //{
InBlock.gif         //    return x * y;
InBlock.gif         //}
InBlock.gif       public static void Add( int x, int y)
InBlock.gif       {
InBlock.gif           int addResult = x + y;
InBlock.gif           MessageBox.Show(addResult+"");
InBlock.gif       }
InBlock.gif       public static void Multiply( int x, int y)
InBlock.gif       {
InBlock.gif           int mulResult = x * y;
InBlock.gif           MessageBox.Show(mulResult+"");
InBlock.gif       }
InBlock.gif    }
InBlock.gif}
2.
InBlock.gif using System;
InBlock.gif using System.Collections.Generic;
InBlock.gif using System.ComponentModel;
InBlock.gif using System.Data;
InBlock.gif using System.Drawing;
InBlock.gif using System.Text;
InBlock.gif using System.Windows.Forms;
InBlock.gif
InBlock.gif namespace DelegateDemo
InBlock.gif{
InBlock.gif     public partial class MainForm : Form
InBlock.gif    {
InBlock.gif         public MainForm()
InBlock.gif        {
InBlock.gif            InitializeComponent();
InBlock.gif        }
InBlock.gif         //public delegate int MyDelegate(int x,int y);
InBlock.gif         public delegate void MulDelegate( int x, int y);
InBlock.gif         private void bt_First_Click( object sender, EventArgs e)
InBlock.gif        {
InBlock.gif             //MyDelegate dele = new MyDelegate(DelegateClass.Add);
InBlock.gif             //int addResult = dele(5, 5);
InBlock.gif             //MessageBox.Show(addResult+"");
InBlock.gif             //MyDelegate dele2 = new MyDelegate(DelegateClass.Multiply);
InBlock.gif             //int multiplyResult = dele2(2 , 3);
InBlock.gif             //MessageBox.Show(multiplyResult+"");
InBlock.gif            MulDelegate mul = new MulDelegate(DelegateClass.Add);
InBlock.gif            mul += new MulDelegate(DelegateClass.Multiply);
InBlock.gif            mul(4, 7);
InBlock.gif            mul -= new MulDelegate(DelegateClass.Add);
InBlock.gif            mul(7, 7);
InBlock.gif        }
InBlock.gif
InBlock.gif    }
InBlock.gif}