Author:Leafwiz From:Internet 在C#2.0中,匿名方法、IEnumerable接口和匿名方法的合作,使很多的编程任务变得非常的简单,而且写出来的程序非常的优美。
比如,我们可以写出如下的代码:
List<Book> thelib = Library.getbooks();
List<Book> found = thelib.FindAll(delegate(Book curbook)
{
if (curbook.isbn.StartsWith("..."))
return true;
return false;
});
foreach (Book b in found)
Console.WriteLine(b.isbn);