序列化Color对象
如下:
public class Class2 { [XmlIgnore] public Color Color1 { get { return color1; } set { color1 = value; } } [XmlElement("Color1"), Browsable(false)] public string _Color1 { get { return ColorTranslator.ToHtml(color1); } set { color1 = ColorTranslator.FromHtml(value); } } private Color color1; }
public class Class2 { [XmlIgnore] public Color Color1 { get; set; } [XmlElement("Color1"), Browsable(false)] public string _Color1 { get { return ColorTranslator.ToHtml(Color1); } set { Color1 = ColorTranslator.FromHtml(value); } } }