Chapter 18. Delegates and Event Programming

This chapter explores one of the new constructs of C# that has no equivalent in the Java programming language. C#'s language API is peppered with uses of this construct. If you examine the threading and I/O APIs, you'll find that the entire asynchronous callback mechanism is based on this new construct, which is called delegates.

Another reason for the support of delegates in C# concerns function pointers, which have been a popular construct in C++ and C but are not supported in Java. Because Java treats everything as a class, the makers of Java did not find the need for a separate construct for function pointers. C#, however, was not meant to lure only Java programmers. C#'s delegates make C and C++ ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.