曾经多次碰到委托,但一直不太明白,今天看着教程做了个小程序,测试一下就明白了,哈哈!

        delegate double ProcessDelegate(double param1, double param2);

        
static double Mutiply(double param1, double param2)
        
{
            
return param1 * param2;
        }


        
static double Divide(double param1, double param2)
        
{
            
return param1 / param2;
        }

 

调用如下:

 

            ProcessDelegate process;
            process 
= new ProcessDelegate(Mutiply);
            Response.Write(process(
4.53.3));
            Response.Write(
"<br>");
            process 
= new ProcessDelegate(Divide);
            Response.Write(process(
10.23.3));