From the course: C#: Delegates, Events, and Lambdas

Unlock the full course today

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

Solution: Programming events

Solution: Programming events - C# Tutorial

From the course: C#: Delegates, Events, and Lambdas

Solution: Programming events

(upbeat music) - [Instructor] Let's take a look at my code for this challenge. And again, let me say, it's not important that you use the same code as me and my solution might not even be the best one. There's always multiple ways of solving almost any given programming problem. So let's open my code file. In my solution I used three different classes. So I have a class for the PiggyBank itself. And then I have a class that logs the balance and that's called the BalanceLogger. And we have a class called the BalanceWatcher that watches the balance to see if we've met our savings goal. And I also have a delicate declaration right at the top up here that defines the signature of the event handler that the PiggyBank class will use to broadcast changes in the balance. So let's look at each of these classes. So starting with the PiggyBank, the PiggyBank class has a private member variable that holds the balance and it has…

Contents