I have a simple XML document that I want to read into an object using the DataContractSerializer in .NET.
<Person>
<Enabled>true</Enabled>
<Name>John Smith</Name>
</Person>
When I read the object, the Enabled field is always false even though the node value is “true.” How does one define XML that will probably deserialize into a boolean true when ReadObject() is called?
It all depends on how you define your class. If you define it as follows, it should read correctly.