【发布时间】:2016-09-06 09:12:18
【问题描述】:
我们如何将ObserableCollection<collectionName> 从 C# 和 WPF 转换为 XML 文件?
【问题讨论】:
-
只编辑问题,没有答案出现?
我们如何将ObserableCollection<collectionName> 从 C# 和 WPF 转换为 XML 文件?
【问题讨论】:
使用此代码购买,我可以轻松地将集合转换为 xml 文件。
static private DataTable ResultsData = new DataTable();
ResultsData = obserableCollectionName().ToDataTable();
System.IO.StringWriter writer = new System.IO.StringWriter();
ResultsData.WriteXml(writer, XmlWriteMode.WriteSchema, false);
string result = writer.ToString();
【讨论】: