Geeks With Blogs
HanSolo code monkey
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");
 
Posted on Saturday, March 21, 2009 6:30 PM | Back to top


Comments on this post: Searching for an item in a list

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © HanSolo | Powered by: GeeksWithBlogs.net