0

I want to ignore all elements of Dictionary while serializing as those members cause an exception

example class:

public class TestClass{
    public string StringTest { get; set; }
    public int IntTest { get; set; }
    public Dictionary<int, string> someDictionary { get; set; }
}

What i tried(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);
4

1 回答 1

0

你有没有像这样尝试过。

[XmlIgnore]
public Dictionary<int.string> someDictionary{get;set;}
于 2010-09-15T14:59:37.213 回答