Properties with just a getter not serializing to XML
-
02-06-2021 - |
Pregunta
I have a class (call it pubs) with some members defined as follows
public string Publisher { get { return PUBLISHER; } }
public string PublisherUrl { get { return PUBLISHER_URL; } }
public DateTime LastBuildDate { get; set; }
Now, an object of this class is serialized and returned as a XMLResult.However, the Publisher and PublisherUrl properties are not part of the XML.
This is being done in the method of my controller which returns an XMLResult (I am using MvcContrib) as follows
return XMlResult(pubs)
Why would the Publisher and PublisherUrl properties not appear in XML?
Solución
XmlSerializer handles only public properties that have both - a public getter and a public setter
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow