Here are the steps (call it denotes sample variable names):
- Create a DataContractSerializer of the type of the DataContract class (call it dcs)
- Create a StringBuilder (call it sb)
- Create an XmlWriter from the string builder ( call it writer)
- use the dataContractSerializer.WriteObject to write the item instance to the xmlwriter.
- Print the sb.ToString to the console.
Fairly intuitive. But just liked it when it saw it in this book.
Heres the code: