//创建listp泛型对象
List<Person> listP = new List<Person>();
//创建类的对象
Person _p1 = new Person() { Name = "谭小龙", Age = 20, Email = "tanxolong@gmail.com" };
//创建类的对象
Person _p2 = new Person() { Name = "汪曾祺", Age = 21, Email = "tanxolong@qq.com" };
listP.AddRange(new Person[] { _p1, _p2 });
//创建文件流
using (FileStream fs = new FileStream(@"xml1988.xml", FileMode.Create, FileAccess.Write))
{
//创建XML序列化器
XmlSerializer _xmlSer = new XmlSerializer(typeof(List<Person>));
//进行xml序列化
_xmlSer.Serialize(fs, listP);
}