本文介绍了关于xmlTextWriter的小问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class SerializeManager<T> {
public string SerializeObject(T pObject) {
string XmlizedString = null;
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(T));
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
xs.Serialize(xmlTextWriter, pObject);
//???-------here---------???//
memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray());
return XmlizedString;
}
我只是不明白这一行:
I just don't understand about this line:
memoryStream = (MemoryStream)xmlTextWriter.BaseStream
在我看来,因为他指定了 memoryStream 在 XmlTextWriter 构造函数中。
只是一个冗余。
真的吗?
in my opinion,because he has specified memoryStream in XmlTextWriter constuctor.
that is only a redundancy.
really?
推荐答案
这篇关于关于xmlTextWriter的小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!