Skip to content

Instantly share code, notes, and snippets.

@jonathanpeppers
Created January 23, 2014 14:03
Show Gist options
  • Save jonathanpeppers/8578877 to your computer and use it in GitHub Desktop.
Save jonathanpeppers/8578877 to your computer and use it in GitHub Desktop.
// An example class, in the real world would talk to a web
// server or database.
public class ProductRepository
{
//OTHER CODE HERE
public async Task<Product[]> SearchProducts(
string searchTerm)
{
// Wait 2 seconds to simulate web request
await Task.Delay(2000);
// Use Linq-to-objects to search, ignoring case
searchTerm = searchTerm.ToLower();
return products.Where(p =>
p.Name.ToLower().Contains(searchTerm))
.ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment