Created
January 23, 2014 14:03
-
-
Save jonathanpeppers/8578877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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