Action和Func的区别

先给段代码:
            //测试使用的公共值
            int num = 10;

            //测试Func委托
            Func<int, int> f;
            f = (int tempf) => { return tempf + 1; };
            Response.Write(f(num).ToString()+"<br />");  //调用f委托,并打印相应的值!

            //测试Action委托
            Action<int> a;
            a = (int tempa) => { Response.Write(string.Format("我不能返回值,所以只能在这里输出了!您的输入参数为: {0}", tempa)); };
            a(num);  //调用a委托方法

主要区别:
Func<t, Result>  封装一个具有一个参数并返回 TResult 参数指定的类型值的方法。
Action<t> 封装一个方法,该方法只采用一个参数并且不返回值。

原文地址:https://www.cnblogs.com/haoliansheng/p/1568246.html