string person = people.Find(person => person.Contains("Joe"));
versus
public string FindPerson(string nameContains, List<string> persons)
{
foreach (string person in persons)
if (person.Contains(nameContains))
return person;
return null;
}
Example code for anonomous function
ReplyDeleteCode:
button1.Click += new EventHandler(button1_Click);
void button1_Click (object sender, EventArgs e)
{
textbox1.Text = DateTime.Now.ToShortDateString();
}
Lambda Code:
button1.Click += (s, e) => { textbox1.Text = DateTime.Now.TosShortDateString(); } ;