C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace Action事件与Func事件
{
class Program
{
static void Main(string[] args)
{
FuncTest a = new FuncTest();
a.funcHandler =new Func<double,double>(a.ReceiveEventHandler);
a.funcEvent += a.funcHandler;
Console.WriteLine( a.Run(1.6));
Console.ReadKey();
}
}
class FuncTest
{
public Func<double, double> funcHandler;
public event Func<double, double> funcEvent;
public double ReceiveEventHandler(double v)
{
return v * 2;
}
public double Run(double v)
{
return funcEvent(v);
}
}
}
打印结果 3.2