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