I have a custom type which i want to serialize, this custom type accepts input which might consists
Posted
by starz26
on Stack Overflow
See other posts from Stack Overflow
or by starz26
Published on 2010-05-25T07:08:00Z
Indexed on
2010/05/25
7:11 UTC
Read the original article
Hit count: 144
.NET
|serialization
I have a custom type which i want to serialize, this custom type accepts input which might consists of escape chars.
M1_Serilizer(MyCustomType customTypeObj) {XmlSerializer serializer = new XmlSerializer(typeof(MyCustomType)); StringWriter sw = new StringWriter(CultureInfo.InvariantCulture); serializer.Serialize(sw, customTypeObj); string str= sw.ToString(); M2_Deserializer(str); }
M2_Deserializer(string str) { XmlSerializer serializer = new XmlSerializer(typeof(MyCustomType)); StringReader sr = new StringReader(str); MyCustomType customTypeObj = (MyCustomType)serializer.Deserialize(sr); }
when escape type chars are part of the CustomTypeObj, on deserialization it throws an exception. Q1)How do i overcome this?, Q2)I should use StringReader and StringWriter and not memorystream or other thing ways. StringWriter/reader will only serve my internal functionality Q3)How can these escape chars be handled?
© Stack Overflow or respective owner