一、实体类转换成XML
将实体类转换成XML需要使用XmlSerializer类的Serialize方法,将实体类序列化
public static string XmlSerialize(T obj)
{
using (StringWriter sw = new StringWriter())
{
Type t= obj.GetType();
XmlSerializer serializer = new XmlSerializer(obj.GetType());
serializer.Serialize(sw, obj);
sw.Close()
1