■
Source Code
The SimpleLambdaExpressions project can be found under the Chapter 11 subdirectory.
Retrofitting the CarDelegate Example Using Lambda
Expressions
Given that the whole reason for lambda expressions is to provide a clean, concise manner to define
an anonymous method (and therefore indirectly a manner to simplify working with delegates), let’s
retrofit the CarDelegate project we created earlier in this chapter. Here is a simplified version of that
project’s Program class, which makes use of “normal” delegate syntax to respond to each callback:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** More Fun with Lambdas *****\n");
// Make a car as usual.
Car c1 = new Car("SlugBug", 100, 10);
Do'stlaringiz bilan baham: |