C# Events – Creating and Consuming Events in Your Application



C# Events – Creating and Consuming Events in Your Application

C# Events - Creating and Consuming Events in Your Application

You almost certainly know what events are in C#. Even if you do not, you’ve probably used them before. What you may not know is how to create your own events. In this video, I am going to introduce you to events and walk you through creating your own events. We will also discuss the features we can take advantage of and what best practices are that we should know about.

Source Code: https://leadmagnets.app/?Resource=CSharpEvents
Patreon: https://patreon.com/IAmTimCorey
Newsletter signup: https://signup.iamtimcorey.com/

0:00 – Intro
1:19 – Demo application walk-through (WinForms)
3:18 – Code behind the demo app
18:28 – Event: Button click
21:21 – Creating and Invoking custom Event
26:35 – Event?.Invoke() explained
30:00 – Listening to and writing code for the Event
34:00 – Creating the custom Event: Event in action and recap
37:12 – Event argument information: debugging
38:42 – Creating Another custom Event (overdraft event)
43:28 – Listening for the event in multiple places
46:33 – Removing Event Listeners from memory
49:00 – Generic EventHandler: Passing class for T
53:39 – why not to use “public set” for properties
59:25 – Exception when to use public set
1:06:13 – Summary

Comments are closed.