Serialize Dictionary to xml using DataContractSerializer
DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary<MeterSetTypeEnum, MeterSet>));
StringBuilder sb = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = " ";
using (XmlWriter writer = XmlWriter.Create(sb, settings))
{
serializer.WriteObject(writer, meters.MeterSets);
StringBuilder sb = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = " ";
using (XmlWriter writer = XmlWriter.Create(sb, settings))
{
serializer.WriteObject(writer, meters.MeterSets);
}