Seeing as you can convert any document to a byte array and save it to disk, and then rebuild the file to its original form (as long as you have meta data for its filename etc.).
Why do you have to mark a class with [Serializable]
etc? Is that just the same idea, "meta data" type information so when you cast the object to its class things are mapped properly?
BinaryFormatter
(which is the main one that cares about this). Most other serializers will do the job, but without biting you when you change the types. – BylineBinaryFormatter
is by far the most powerful. It serializes fields and properties, it serializes the whole object including private fields, and it supports cyclic references, plus it bypasses object construction, thus does not require a public default constructor, none of which e.g. theXmlSerializer
provides. If you want to change types, you'll have to cope with versioning. – Polarization