三者都是对委托的简写,少了部分委托的声明
Action相当于可以带很多参数的无返回值的委托
public Action<string, int> action; public void Action1(string str,int a) { print(str + a.ToString()); } action = Action1;
Func可以带很多参数,但是必须带返回值的委托
Func<T1,T2,T3,T4,TResult> func;
public Func<string , bool> func; public bool Func1(string str) { print(str); return true; }
EventHandler可以带一整个参数列表,无返回值
public event EventHandler<StudentClass> showStudentInfo; StudentClass student = new StudentClass("12","lp","man"); private void Test(EventHandler eventHandler) { eventHandler(this ,student); } //其中 写类对参数列表类进行继承 public class StudentClass : EventArgs { public string age; public string name; public string sex; public StudentClass(string _age,string _name,string _sex) { age = _age; name = _name; sex = _sex; }