Delegates and Events C# Help

Callback functions are an important part of programming in Windows. If you have a background in C or C++ programming, you have seen callbacks used in many of the Windows APIs. With the addition of the Address Of keyword, Visual Basic developers are now able to take advantage of the API that once was off limits. Callback functions are really pointers to a method call. Also known as function pointers, they are a very powerful programming feature ..NET has implemented the concept of a function pointer in the form of delegates. What makes them special is that, unlike the C function pointer, the .NET delegate is type-safe. What this means is that a function pointer in C is nothing but a pointer to a memory location. You have no idea what that pointer is really pointing to. This is like parameters and return types are not known. As you see in this chapter, .NET has made delegates a type-safe operation. Later in the chapter, you see how .NET uses delegates as the means of implementing events.

The main topics of this chapter are:

  1.  Delegates
  2.  Anonymous methods
  3.  Lambda expressions ••
  4.  Events

Posted on October 28, 2015 in Delegates and Events

Share the Story

Back to Top
Share This