c#学习笔记――委托

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

         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.5 3.3 ));
            Response.Write(
" <br> " );
            process 
=   new  ProcessDelegate(Divide);
            Response.Write(process(
10.2 3.3 ));

你可能感兴趣的:(.net,Web,mvc,C#,it)