XML serialization of enums

后端 未结 5 2017
悲&欢浪女
悲&欢浪女 2021-01-02 08:54

I have problems with serializing enum values.

Here is the code:

[System.Xml.Serialization.XmlRootAttribute(Namespace = \"\", IsNullable = false)]
pub         


        
5条回答
  •  再見小時候
    2021-01-02 09:37

    I found what was wrong. For every enum type

    [System.Xml.Serialization.XmlAttributeAttribute()]
    public REQUESTTypetype Type;
    

    I got this:

    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool TypeSpecified;
    

    And in the code I should do this:

    request.Type = REQUESTTypetype.One;
    request.TypeSpecified = true;
    

    It works fine now. I should have post them in my question but I did not pay attention to these "specified" members at all. Thanks for your replies.

提交回复
热议问题