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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access