我有一个要反序列化的 XML 文件,有趣的是 XML 文件是使用以下代码序列化的:
enter code here
var serializer = new XmlSerializer(typeof(CommonMessage));
var writer = new StreamWriter("OutPut.txt");
serializer.Serialize(writer, commonMessage);
writer.Close();
我试图再次反序列化它以检查输出是否与输入匹配。无论如何,这是我反序列化的代码:
var serializer = new XmlSerializer(typeof(CommonMessage));
var reader = new StringReader(InputFileName);
CommonMessage commonMessage = (CommonMessage)serializer.Deserialize(reader);