1 //整理输出数据 2 List<RowData> lisOutputData = new List<RowData>(); 3 foreach (var item in dicAssist.Keys) 4 { 5 string key = item + dicAssist[item]; 6 foreach (var itm in dicRowNumber[key]) 7 { 8 lisOutputData.Add(dicRowData[itm]); 9 } 10 } 11 Console.WriteLine("Excel数据读取并整理完成!" + Environment.NewLine); 12 13 14 //序列化集合为xml文件 15 Console.WriteLine("序列化集合为XML文件......"); 16 17 var reader = new XmlSerializer(typeof(List<RowData>)); 18 //写入文件 19 using (var fs = File.OpenWrite(localEcnDataXmlFilePath)) 20 { 21 reader.Serialize(fs, lisOutputData); 22 }
1 //反序列化XML文件为集合 2 var reader = new XmlSerializer(typeof(List<RowData>)); 3 basicEcnData = new List<RowData>(); 4 using (var fs = File.OpenRead(localEcnDataXmlFilePath)) 5 { 6 basicEcnData = reader.Deserialize(fs) as List<RowData>; 7 }
标签:XML,C#,List,reader,var,new,序列化 From: https://www.cnblogs.com/xuanyuanhw/p/17352171.html