Case Study – Event Practice in C#

In C# practice, we always use Event as an observer for property modification. In this post, I am sharing a practice case regarding piggy bank monitoring. Background A piggy bank can help us with saving an amount of money that we planned. Every time, we deposit gold coins into the piggy bank, the balance will…

C# Case Study – Delegate as a Method in Practice

Case Background A courier company ships parcels in the local area. There are four zones in the company’s business area. The shipping fees are a certain percentage of the given item price. Some destinations are a bit dangerous or far from the company’s depot, which has an additional risk fee $25. Zone 1 – 25%…

Event in C#

Event in C# is based on the mechanism that delegate used to work.  Event is useful for broadcasting information (or message) to and receiving data (or message) from other parts of the program.   Event allows the program to communicate asynchronously and help us build a more responsive application.  Besides, Event can be switched on and off as…

Delegate in C#

Delegate is a way that we can declare a variable that holds a reference to a function in our program.  It gives us an opportunity to change the function that will be called at a run time.  Besides, Delegate gives us a way to logically separate different parts of our application from each other, without having to…