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 live online training, plus books, videos, and digital content from nearly 200 publishers.