We begin by creating and writing serialized objects to a sequential-access file. In this section, we reuse much of the code from Section 17.5, so we focus only on the new features.
Let’s modify class
Record (Fig. 17.8) so that objects of this class can be serialized. Class
RecordSerializable (Fig. 17.13; part of the
BankLibrary project) is marked with the [Serializable] attribute (line 7), which indicates to the CLR that
RecordSerializable objects can be serialized. Classes that represent serializable types must include this attribute in their declarations or must implement interface ISerializable.
1 // ...