<p>I've read that Lambda Expressions are an incredibly powerful addition to C#, yet I find myself mystified by them. How can they improve my life or make my code better? Can anyone point to a good resource for learning such expressions?</p>

<p>They seem cool as hell, but how do they relate to my day-to-day life as an asp.net developer?</p>

<p>Edit: Thanks for the examples, and thanks for the link to Eric White's articles. I'm still digesting those now. One quick question: are lambda expressions useful for anything other than querying? Every example I've seen has been a query construct.</p>

[{'answer_id': 25385, 'author': 'Brian Leahy', 'author_id': 580, 'author_profile': 'https://Stackoverflow.com/users/580', 'pm_score': 3, 'selected': False, 'text': '<p>Lambdas bring functional programing to C#.\nThey are anonymous functions that can be passed as values to certain other functions.  Used most in LINQ.</p>\n\n<p>Here is a contrived example:</p>\n\n<pre><code>List&lt;int&gt; myInts = GetAll();\nIEnumerable&lt;int&gt; evenNumbers = myInts.Where(x =&gt; x % 2 == 0);\n</code></pre>\n\n<p>Now when you foreach through evenNumbers the lamda </p>\n\n<pre><code>x=&gt; x % 2 == 0\n</code></pre>\n\n<p>is then applied as a filter to myInts.</p>\n\n<p>They become really useful in increasing readability to complicated algorithms that would have many nested IF conditionals and loops. </p>\n'}, {'answer_id': 25391, 'author': 'Corey', 'author_id': 1595, 'author_profile': 'https://Stackoverflow.com/users/1595', 'pm_score': 3, 'selected': False, 'text': "<p>Here's a simple example of something cool you can do with lambdas:</p>\n\n<pre><code>List&lt;int&gt; myList = new List&lt;int&gt;{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };\nmyList.RemoveAll(x =&gt; x &gt; 5);\n//myList now == {1,2,3,4,5}\n</code></pre>\n\n<p>The RemoveAll method takes a predicate(a delegate that takes argurments and returns a bool), any that match it get removed.  Using a lambda expression makes it simpler than actually declaring the predicate.</p>\n"}, {'answer_id': 25412, 'author': 'Will Dean', 'author_id': 987, 'author_profile': 'https://Stackoverflow.com/users/987', 'pm_score': 5, 'selected': True, 'text': '<blockquote>\n  <p>: are lambda expressions useful for anything other than querying</p>\n</blockquote>\n\n<p>Lamba expressions are nothing much other than a convenient way of writing a function \'in-line\'.</p>\n\n<p>So they\'re useful any place you wanted a bit of code which can be called as though it\'s a separate function but which is actually written inside its caller.  (In addition to keeping related code in the same location in a file, this also allows you to play fun games with variable scoping - see \'closures\' for a reference.)</p>\n\n<p>An example of a non-query-related use of a lamba might be a bit of code which does something asynchronously that you start with ThreadPool.QueueUserWorkItem.  The important point is that you could also write this using anonymous delegates (which were a C#2 introduction), or just a plain separate class member function.</p>\n\n<p>This <a href="http://blogs.msdn.com/jomo_fisher/archive/2005/09/13/464884.aspx" rel="noreferrer">http://blogs.msdn.com/jomo_fisher/archive/2005/09/13/464884.aspx</a> is a superb step-by-step introduction into all this stuff, which might help you.</p>\n'}]
['https://Stackoverflow.com/questions/25376', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2757/']