c# - 在 C# 错误 "String cannot be of zero length. Parameter name: oldValue"中使用 linq to xml 创建动态 xml 文件

标签 c# xml linq-to-xml

错误截图如下

enter image description here

enter image description here enter image description here

我想发生的是动态创建一个 xml 文件,xml 的节点将是 string[] textBoxNamesArray,值将是 string[] textBoxTextArray

如何解决这个问题?

最佳答案

问题在于对 String.Replace 的调用。 The first argument cannot be an empty string .并且由于您将 ""替换为 string.Empty,所以实际上不需要调用,可以将其删除。

所以把这一行改成

xml.Add(new XElement(i, o));

关于c# - 在 C# 错误 "String cannot be of zero length. Parameter name: oldValue"中使用 linq to xml 创建动态 xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13676934/

相关文章:

c# - 为什么 Equals 没有按预期工作

c# - 在 C# 中创建或替换没 Root过的 XML 中的节点

独立于行选择的 C# DataGridView 复选框

php - 如何在 PHP 中将 XML 转换为数组?

java - 从 Java 中的 API 解析 Last.Fm XML

linq - 这些是使用 LINQ 的不当方式吗?

c# - 枚举文件抛出异常

C# winform,如何使轨迹条随着声音文件移动(增加其值)?

javascript - 资源加载失败 - 内部服务器错误

jquery - 来自 Chrome 扩展的 jQuery AJAX 调用问题