0
我想忽略詞典中的所有元素,而序列化特定類型的所有成員的成員會導致異常序列化如何動態地忽略
例如類:
public class TestClass{
public string StringTest { get; set; }
public int IntTest { get; set; }
public Dictionary<int, string> someDictionary { get; set; }
}
我想什麼(unsuccessfull)
XmlAttributeOverrides xOver = new XmlAttributeOverrides();
XmlAttributes attrs = new XmlAttributes();
attrs.XmlIgnore = true;
xOver.Add(typeof(Dictionary<int, string>), attrs);
XmlSerializer serialiser = new XmlSerializer(objectToConvert.GetType(), xOver);
serialiser.Serialize(writer, objectToConvert);
的可能重複[爲什麼沒有在.NET中的XML序列化的詞典嗎?(http://stackoverflow.com/questions/1124597/why-isnt-there-an-xml-serializable-字典在網) – 2010-09-15 15:31:44