make XmlElement optional in c#



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?


No comments:

Post a Comment