C# Programming: Mastering Delegates & Events

Published 2022-07-08
Platform Udemy
Rating 5.00
Number of Reviews 4
Number of Students 7
Price $84.99
Instructors
Andrew Hemmings
Subjects

Go to Udemy

This course teaches you delegates and events in C# and how to build efficient, powerful applications.

Welcome to this course. A delegate is a type that represents references to methods with a particular parameter list and return type. When you instantiate a delegate, you can associate its instance with any method with a compatible signature and return type. You can invoke (or call) the method through the delegate instance. Delegates are used to pass methods as arguments to other methods. Event handlers are nothing more than methods that are invoked through delegates. You create a custom method, and a class such as a windows control can call your method when a certain event occurs. Events are user actions such as key press, clicks, mouse movements, etc., or some occurrence such as system generated notifications. Applications need to respond to events when they occur. For example, interrupts. Events are used for inter-process communication. People often find it difficult to see the difference between events and delegates. C# adds on value to the often mentioned world of event driven programming by adding support through events and delegates. It doesn't help matters by allowing you to declare field-like events which are automatically backed by a delegate variable of the same name. This course aims to clarify the matter for you. The events are declared and raised in a class and associated with the event handlers using delegates within the same class or some other class. The class containing the event is used to publish the event. This is called the publisher class. Some other class that accepts this event is called the subscriber class. Events use the publisher-subscriber model.

In this course, you'll learn:

Go to Udemy