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 關(guān)注
- 732 瀏覽
添加回答
舉報(bào)
0/150
提交
取消