lambda expression and event handler?

.net, c#, c#-4.0

Solution

You can use a lambda expression to build an anonymous method, which can be attached to an event.

For example, if you make a Windows Form with a `Button` and a `Label`, you could add, in the constructor (after `InitializeComponent()`):

 this.button1.Click += (o,e) =>
     {
        this.label1.Text = "You clicked the button!";
     };

This will cause the label to change as the button is clicked.

Problem

Someone mentioned to me that c# supports to use lambda expression as event handler, can anyone share with me some reference on this? A code snippet is preferred.

Original source

Related problems