It's cool to see how the .Net framework has evolved from 1.1 to 2.0 and to 3.5. Searching for items in a list is a pretty common programming task. This is a comparison of how list searching has changed throughout the different .Net framework versions.
//.Net 1.1 search using a foreach statement
foreach (Customer cust in customerList)
{
if (cust.FirstName == "Bill")
{
customer = cust;
break;
}
}
//.Net 2.0 search using a inline delegate
Customer cust = customers.Find(
delegate(Customer c)
{
return c.FirstName == "Bill";
});
//.Net 3.5 search using a lambda expression
Customer cust = customers.Find(C => C.FirstName == "Bill");