Consuming events in .NET is possible on couple of ways. So, if object type Car contains an event SaySpeed it can be consumed on the following ways:
- Usual way
car.SaySpeed += car_SaySpeed;
where car_SaySpeed is function which implements SaySpeed delegate like:
void car_SaySpeed(object sender, CarEventArgs e) { ... }
- Another method is by using anonymous methods as
car.SaySpeed += delegate { ... };
- And a clean one, by using lambda expressions
car.SaySpeed += (sender, e) => { ... };