From the course: Advanced C# Programming Concepts

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Solution: Lambda functions

Solution: Lambda functions - C# Tutorial

From the course: Advanced C# Programming Concepts

Solution: Lambda functions

(upbeat music) - [Instructor] Let's take a look at my solution code. So remember that in the previous solution, we used a separate class, or at least I did, to implement the event handler, to log the balanced changed messages. And what I've done is in this case, I've replaced that class with a static function with this inline Lambda function that outputs the message directly so it implements the same function signature as the event handler, right? So if we scroll back up, you can see that the two values here, the old value and the new value, and here we have the old amount and new amount. So it's the same event handler function and the output will be the same. So let's go ahead and run my code and we'll run this. And you can see that the output is the same. The main difference is that instead of having a separately defined class, the logic is defined in the Lambda, right where it is used.

Contents