没有参数
此示例显示如何创建封装返回当前时间的方法的委托
static DateTime UTCNow()
{
return DateTime.UtcNow;
}
static DateTime LocalNow()
{
return DateTime.Now;
}
static void Main(string[] args)
{
Func<DateTime> method = UTCNow;
// method points to the UTCNow method
// that retuns current UTC time
DateTime utcNow = method();
method = LocalNow;
// now method points to the LocalNow method
// that returns local time
DateTime localNow = method();
}