I have a custom type which i want to serialize, this custom type accepts input which might consists
- by starz26
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?