賛否両論なラムダ式
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Program { class Person { public int Age { get; set; } public string Name { get; set; } } class Program { static void Main(string[] args) { List<Person> persons = new List<Person>(); persons.Add(new Person { Age = 22, Name = "Akira" }); persons.Add(new Person { Age = 38, Name = "Bob" }); persons.Add(new Person { Age = 13, Name = "Millia" }); foreach (Person person in persons.FindAll(target => target.Age >= 18)) { Console.WriteLine("年齢:{0}, 名前:{1}", person.Age, person.Name); } } } }
匿名delegateのわかりきった部分を排除したもの
個人的には好き