在C#语言的using system的命名空间下,有两个内置委托:Action与Func   1.Action委托(都没有返回值): Action:无参,无返回值; Action16 个),无返回值;   2.Func委托(都有返回值): Func16个),返回值为T   代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace actionAndFunc
{
    class Program
    {
        static void Main(string[] args)
        {
            //定义Action委托,无参数,无返回值
            Action act01;
            //使用Lambda表达式添加方法语句块
            act01 = () => Console.WriteLine(“我是Action无参数的委托”);
            act01();
        //定义Action委托,有1个参数,无返回值
        Action<int> act02;
        act02 = (int a)=>Console.WriteLine("我是Action有1个参数的委托{0}",a);
        act02(666);
        //定义Action委托,有2个参数,无返回值
        Action<int, string> act03;
        act03 = (int a, string str) =>
        {
            Console.WriteLine("我是Action有2个参数的委托,第一个参数是{0},第二个是{1}",a,str);
        };
        act03(666,"sixsixsix");
        Console.WriteLine("-----------------------------------------------------------------");
        Console.WriteLine("-----------------------------------------------------------------");
        //定义Func委托,没有参数,返回值是int
        Func<int> func01;
        func01 = () =>
        {
            Console.Write("一个无参数的Func委托,返回值是:");
            return 666;
        };
        var temp = func01();
        Console.WriteLine(temp);
        //定义Func委托,有两个string参数,返回值是int,注意返回值是在<>的最后一个
        Func<string, string, int> func02;
        func02 = (string str01, string str02) =>
          {
              Console.Write("{0}一个无参数的Func委托{1},返回值是:",str01,str02);
              return 666;
          };
        var Temp = func02("我是","类型");
        Console.WriteLine(Temp);
        Console.ReadKey();
    }
}}
运行结果:[
                    
                    
                ](http://www.wjgbaby.com/wp-content/uploads/2017/08/17081901.png) ](http://www.wjgbaby.com/wp-content/uploads/2017/08/17081901-300x176.png)
                ](http://www.wjgbaby.com/wp-content/uploads/2017/08/17081901-300x176.png)