I had a quick question regarding the datacontractserializer. Maybe it\'s more of a stream question. I found a piece of code that writes the xml to a filestream. I basically don\
Thanks to @xr280xr for pointing out my forgotten StringWriter disposal in the first draft.
///
/// Converts this instance to XML.
///
/// XML representing this instance.
public string ToXml()
{
var serializer = new DataContractSerializer(this.GetType());
using (var output = new StringWriter())
using (var writer = new XmlTextWriter(output) { Formatting = Formatting.Indented })
{
serializer.WriteObject(writer, this);
return output.GetStringBuilder().ToString();
}
}