To serialize an object graph in C#, two common approaches are using BinaryFormatter or XmlSerializer. Here are examples of both:
Using BinaryFormatter:
main.cs530 chars20 lines
Using XmlSerializer:
main.cs511 chars19 lines
In both cases, the serialized output will be saved to a file, which can later be deserialized to re-create the original object graph.
gistlibby LogSnag