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; } } 為什么編譯不通過(guò)
無(wú)法從用法中推導(dǎo)出方法
慕桂英4014372
2018-09-14 06:07:47