Creating and Implementing Events and Callbacks

This chapter focuses on events and callbacks in C#. They are important to understand since they give us more control over programs. An event is a message or notification from an object when either its property has been changed or a button has been clicked. A callback, also known as a delegate, holds a reference to a function. C# comes with Lambda expressions, which can be used to create delegates. These are also called anonymous methods.

We will also spend some time looking at a new operator, known as a Lambda operator. These are used in Lambda expressions. They were introduced in version 3.0 of C# so that developers could instantiate delegates. Lambda expressions replaced the anonymous methods that were introduced in C# 2.0 and are now widely used.

In this chapter, we will be covering the following topics:

  • Understanding delegates
  • Handling and raising events

By the end of this chapter, you will know what delegates are and how you can use them in events and callbacks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.232.239