If you want more control over what is serialized, you should implement ISerializable on your object. This gives a developer complete control over what is serialized. Note that you still need to add the [ISerializable] attribute to your object. Lastly, the developer also needs to implement a deserialization constructor. Using ISerializable, however, does have a caveat. According to the MSDN, the forward compatibility of your object with newer versions of the .NET Framework and any improvements made to the serialization framework might not be applicable on your object. You also need to implement ISerializable on all the derived types of your object.
Using ISerializable for custom serialization to a FileStream
Getting ready
We will create a new class that wants to control...