【问题标题】:How to convert an ObservableCollection to XML file from C#?如何将 ObservableCollection 从 C# 转换为 XML 文件?
【发布时间】:2016-09-06 09:12:18
【问题描述】:

我们如何将ObserableCollection<collectionName> 从 C# 和 WPF 转换为 XML 文件?

【问题讨论】:

  • 只编辑问题,没有答案出现?

标签: c# xml wpf


【解决方案1】:

使用此代码购买,我可以轻松地将集合转换为 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();

【讨论】:

  • obserableCollectionName() 是什么意思?我没有关注
猜你喜欢
  • 2013-11-05
  • 1970-01-01
  • 1970-01-01
  • 2020-03-21
  • 1970-01-01
  • 2011-07-12
  • 2018-12-02
  • 2023-03-23
  • 1970-01-01
相关资源
最近更新 更多