class Program { static void Main(string[] args) { List<Person> persons = new List<Person>() { new Person{ID= ...
class Program { static void Main(get='_blank'>string[] args) { List<Person> persons = new List<Person>() { new Person{ID=101,Name="lin1"}, new Person{ID=102,Name="lin2"}, new Person{ID=103,Name="lin3"} }; Person person = persons.Find( delegate(Person p) //this is an anonymous method. { return p.ID == 101; } ); Person p1 = persons.Find(p=>p.ID==101);//using lambda expression Person p2 = persons.Find((Person p)=>p.ID==101);//you can also explicitly the input type but no required Console.WriteLine("person id={0},name={1}", person.ID, person.Name); } } class Person { public int ID { get; set; } public string Name { get; set; } }
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:Part 99 Lambda expression in c#
关键词:C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。