class Program { public delegate T myDel<U,T>(U u); static void Main(string[] args) { List<Person> personList = new List<Person>(){ new Person{ Age=12,Name="孙俩岁" }, new Person{ Age=13,Name="dfsdfs" }, new Person{ Age=42,Name="dsf" }, new Person{ Age=22,Name="ffhtr" } }; myDel<Person, bool> myd = new myDel<Person, bool>(getPs); // Func<Person, bool> myd = getPs; var lists = personList.Where(myd); foreach (var l in lists) { Console.WriteLine(l.Age); } Console.ReadKey(); } public static bool getPs(Person p) { return p.Age > 20; } } public class Person { public string Name { get; set; } public int Age { get; set; } } 为什么编译不通过
- 3 回答
- 0 关注
- 704 浏览
添加回答
举报
0/150
提交
取消