C#的Action与Func

1.Action不返回值Action<int,string>都是参数的类型

2.Func返回值Func<int>里面一个参数表示返回值的类型

  Func<int,double>两个参数,第一个表示入参的类型,最后那个表示返回值的类型,以此类推

示例: Func<string,int, string> st =(o,p) => (o+p).ToUpper();

           Action<int> cc = (o) => { };

   public static void Methods(string s,int i) {
            Console.WriteLine(string.Format("我叫{0},今年{1}岁",s,i));

     }

    Action<int> mm=new Action<int>(Methods);

    mm("小白",20)

      public static string Jia(int a,int b) {
            return a.ToString()+b;

        }

扫描二维码关注公众号,回复: 3009598 查看本文章

       Func<int, int,string> j = new Func<int, int,string>(Jia);
        j(10, 20);


猜你喜欢

转载自blog.csdn.net/qq_35534449/article/details/80860486