I use REST (XML) for client-server communication. The given example should be read from my Channel.
[XmlRoot("Device")]
public class RestDevice
{
[DataMember]
[XmlElement("type")]
public string Type { get; set; }
}
I would like to make the XmlElement "type" optional (so that if the root doesn't contain one, I will get null as the Type property of class RestDevice.
How can I do that?
[XmlElement(ElementName = "type", IsNullable = true)]
public string Type;
Is what you are looking for.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.