对序列中每一项进行“先来后出”式的执行,代码中间处理很好
static int M(ints, Func<int> f)
{
Console.Write(s);
varn= f();
Console.Write(s);
returnn;
}
private static void Main(string[] args)
{
Func<int> f = () =>
{
Console.Write("A");
return100;
};
IList<int> l = newList<int>() {1, 2, 3};
var doit = l.Aggregate(f, (current, i) => (() => M(i, current)));
doit();
}
输出:321A123