How does a lambda expression work? (CSharp)?

This isn't really going to be an answer to your question... more of a comment on it.... :) It's not clear what it is that you really want to know, and what you already understand. It seems like you might want an explanation of one or more of the following... - What is a lambda expression? - Why would you use a lambda expression?

- How do you use lambda expressions in C#? - How does C# implement lambda expressions? If you can clarify what you already understand and what you don't, it'll probably help you get a good answer.

A lambda expression is like an inline delegate. The argument for methods that accept an expression can be written like this: Func expression where Customer is the type of argument and bool is the return type. So in the example you have underlined: the "c=>" part is telling the FirstOrDefault extension method that you are going to use the name "c" to represent the argument passed to the function and the "c.

CustomerID == cid" represents the boolean value that will be returned. For a generic list of customers or a List the underlined statement is similar to doing this var cust = myList. Find(delegate(Customer c){return c.

CustomerID == cid}); Expressions are extremely powerful when you use them with generics. You can build very useful classes that can extend other classes or be used as utilities. To further your understanding of these expressions and how they are actually working, I recommend you use http://www.red-gate.com/products/reflector/ to take a look at the System.Linq.

Extensions class and it's methods. There is a wealth of information in there.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions