1. Using a generic delegate
=> foreach (Customer c in Customers.Where(new Func<Customer, bool>(MatchName)) {}
bool MatchName(Customer c) { return c.CustomerID.StartsWith("L"); }
2. Using an anonymous delegate
=> foreach (Customer c in Customers.Where(delegate(Customer c) { return c.CustomerID.StartsWith("L")}) {}
3. Using a lambda expression
=> foreach (Customer c in Customers.Where(c => c.CustomerID.StartsWith("L"))) {}
4. Using as LINQ query expression
=> var query = from c in Customers where c.CustomerID.StartsWith("L") orderby c.CustomerID select c;
foreach (Customer c in query) { }
'Framework' 카테고리의 다른 글
LINQ 코드를 이용한 Paging 처리 방법 (0) | 2010.06.15 |
---|---|
Different with ArrayList, List<T> - Boxing, None Boxing(샘플 소스) (0) | 2009.11.25 |
LINQ 자료 (2) | 2009.10.09 |
C# Collection Classes (부제:List 와 ArrayList 의 차이 ) (0) | 2009.10.06 |
Different ways of reading and writing text file data in .NET (0) | 2009.09.21 |