Video Tutorial Library:

C# 301 - C# 3.0 Language Enhancements :

CS301_06_01 - Lambda Expressions

Tags:
In this video we talk about the last major topic before we plunge into LINQ and so we'll be talking about Lambda Expressions.  If you are planning on using LINQ a lot, then you'll definitely be writing a lot of lambda expressions.  What are they?  Lambda Expressions are basically shorthand for anonymous delegates.  For me, that statement  was a bit hard to swallow. What does that really mean?  So, in this video we'll start out with delegates, move to anonymous methods, then move to lambda expressions to show the progression of thought.  But basically, you can think of an anonymous delegate as a little chunk of code that you can pass around as an object.  Physically, it's a pointer to some function, but that sometimes is a bit nebulous.  Said antoher way, Lambdas are short expressions that evaluate to some value.  Let's stick with the idea of a little chunk of code that you can pass around.  And the idea here is that you can stick this little block of code right into the parameter of a function call.  And the reason this is useful is because they are used in LINQ usually for one of three purposes ... 1) either as a predicate, which means that the little chunk of code is used to filter out a set of items based on the condition in your little chunk of code, 2) It's used as a selector thats used to "pick" something ... a good example is when you need to convert a list of OrderItems using LINQ's ToDictionary method.  ToDictionary needs a key, so you can use a selector lambda to choose which field will act as the key for the new Dictionary of OrderItems.  3) or it's used as a projection ... which means that your little chunk of code is used to change one type into another type.

Downloads:

Sign up today to access downloads.
CS301_06_01 - Lambda Expressions
Duration: 19 Minutes, 42 Seconds
Size: 24.10M
Recorded Using: Visual Studio 2008 (all versions)

Get Free Videos via Email

Sign up for our newsletter and receive links to free videos and more.

Subscribe

We don't rent/sell/or commit other evil deeds with your email address. See our Privacy Policy.