委托都是传方法的啊// Declare delegate -- defines required signature:
delegate double MathAction(double num);class DelegateTest
{
    // Regular method that matches signature:
    static double Double(double input)
    {
        return input * 2;
    }    static void Main()
    {
        // Instantiate delegate with named method:
        MathAction ma = Double;        // Invoke delegate ma:
        double multByTwo = ma(4.5);
        Console.WriteLine(multByTwo);        // Instantiate delegate with anonymous method:
        MathAction ma2 = delegate(double input)
        {
            return input * input;
        };        double square = ma2(5);
        Console.WriteLine(square);        // Instantiate delegate with lambda expression
        MathAction ma3 = s => s * s * s;
        double cube = ma3(4.375);        Console.WriteLine(cube);
    }
}

解决方案 »

  1.   

    委托都是传方法(名)的。
    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication1
    {
        public delegate string myDelegate();    class Program
        {
            static void Main(string[] args)
            {
                myDelegate de = new myDelegate(say);            myDelegate de2 = new myDelegate(sayTwo);            Console.WriteLine(de());
                Console.WriteLine(de2());
            }        public static string say() 
            {
                return "say1";
            }        public static string sayTwo()
            {
                return "say2";
            }
        }
    }
    签名(方法参数和返回类型)相同
      

  2.   

    给你推荐一个博客吧,写的很详细
    http://www.tracefact.net/CSharp-Programming/Delegates-and-Events-in-CSharp.aspx
      

  3.   

    delegate 一个委托 比如是GATE
    然后用这个委托定义实例 GATE Gate1
    把相应的函数赋值就好了
      

  4.   


    using System;
    using System.Collections.Generic;
    using System.Text;namespace control
    {
        class Program
        {
            public delegate void Mydelegate(string str);//定义一个委托
            static void Main(string[] args)
            {
                Mtd mtd = new Mtd();//实例化一个Mtd类
                Mydelegate mydlg = new Mydelegate(mtd.method);//给委托签名method方法
                mydlg("ssss");
            }
         }
        class Mtd
        {
        
           public void method(string str)//定义一个方法
            {
                Console.WriteLine(str);
            }
        }
    }应该是这样吧!!如果有什么问题也可以互相交流
    QQ:214004202
      

  5.   

    1楼比较全,分别是:1.把方法直接赋给委托的实例。2.匿名委托,就是把匿名方法赋给委托实例 3.把lambda表达式赋给委托的实例。
    还有就像7楼用构造函数创建委托的实例。