[C#] XML Serialize Attribut / Element必须具有值

时间:2013-09-08 13:28:51

标签: c# xml-serialization xml-attribute

XMLIgnoreAttribute VARSpecified 忽略或忽略值。

但指定的任何属性是否必须有值?

我找到了Attributes That Control XML Serialization,但没有用。

class Test
{
    [XMLIgnore]
    public string IgnoredValue;

    [XMLAttribute]
    public string AnAttribute;

    // If 'AnAttribute' length < 5 will be ignored
    public bool AnAttributeSpecified{get {return AnAttribute.Length > 5;};}

    // For this, it must have a value, is there any attribute for this?
    public string Name;
}

0 个答案:

没有答案