2010-01-27

Resharper 提示”lambda expression to statement”

最近用上了resharper,实时对代码进行改进,碰到这么一个提示“lambda expression to statement”,那什么是lambda expression,什么是lambda statement?二者有什么区别?

Expression:
var exprBooks = books.Find(book => book.Author.Contains("Fowler"));


Statement:

var stmtBooks = books.Find(book => { return book.Author.Contains("Fowler"); });



A lambda statement contains braces and a function body, and can potentially have multiple lines like a standard delegate. A lambda expression is the single line with an implicit return



http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/07/18/expressions-and-lambdas.aspx

No comments: