Thursday, July 16, 2009

Code Snippet: List<T>.Exist()

Find the given product in the list of saved product

List<Product> savedProducts = Repository.GetSavedProducts();
Product item = (Product)dataItem.DataItem;
bool found = savedProducts.Exists(delegate(Product p) { return a.ProductName == item.ProductName; });

No comments:

Post a Comment

About Me

Software developer specializing in Microsoft technologies.