Func<> 与Action<>

Func< >   封装一个具有一个参数并返回 TResult 参数指定的类型值的方法,

Action<T> 委托封装一个方法,该方法只有一个参数并且不返回值。            

其实都是一个委托

Main()

{

            Func<int, string > fun =p.Name;//int是委托要执行的方法的参数类型,string 是方法的返回值类型
            int age = 22;
            Console.WriteLine( fun(age));

}

 public class Person
    {
        public  string Name(int  age)
        {
            return age.ToString();
        }
    }

原文地址:https://www.cnblogs.com/http-www/p/3509865.html