111,097
社区成员




public static string SerializeToXml(object srcObject, Type type)
{
type = type != null ? type : srcObject.GetType();
XmlSerializer xs = new XmlSerializer(type);
StringBuilder stb = new StringBuilder();
XmlWriter xw = XmlWriter.Create(stb);
xs.Serialize(xw, srcObject);
return stb.ToString();
}
public static string SerializeToXml(object srcObject, Type type)
{
type = type != null ? type : srcObject.GetType();
XmlSerializer xs = new XmlSerializer(type);
StringBuilder stb = new StringBuilder();
XmlWriter xw = XmlWriter.Create(stb, new XmlWriterSettings(){Encoding = UTF8Encoding.UTF8});
xs.Serialize(xw, srcObject);
return stb.ToString();
}