Serializing delegates

Delegates implement the ISerializable interface so that the Delegate class can be persisted in a serialized form. Serialization is a topic that will be developed more fully in Chapter 17, but for now just note that the class can be persisted to a file, either as text (SoapFormatter) or as a binary image (BinaryFormatter). The BinaryFormatter produces considerably less data than the SoapFormatter, but it is proprietary to Microsoft and it is not very readable. Your application might require the BinaryFormatter, but this chapter will focus on the SoapFormatter. Changing from one formatter to another is simple.

Listing 14.20 shows a delegate being serialized to a file “static-delegate.xml” and then deserialized from that same ...

Get .NET Common Language Runtime Unleashed 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.