-
Notifications
You must be signed in to change notification settings - Fork 77
XmlSerialization
Rico Suter edited this page Jun 3, 2015
·
2 revisions
- Package: MyToolkit
- Platforms: All (PCL)
Used to serialize and deserialize an object to XML (using the .NET XML serializer). By default, the serializers are internally cached to improve the serialization process for multiple objects of the same type.
var person = new Person();
...
var xml = XmlSerialization.Serialize(person);
var person2 = XmlSerialization.Deserialize<Person>(xml);
Note: Use the BCL .NET XmlAttribute
, XmlTag
, XmlIgnore
, etc attributes to control the serialization process...
If you have circular references use the DataContractSerialization class and the preserveReferences option because the XML serializer does not support circular references and will eventually throw a StackOverflowException
.
Additional methods:
- SerializeAsync()
- DeserializeAsync()