这个可以正常工作:
XDocument xdoc = new XDocument(
new XDeclaration("1.1", "UTF-8", "yes"),
new XProcessingInstruction("foo", "bar"),
new XElement("test"));
但是如果我将它改为将“参数数组”显式地作为一个数组传递:
object[] content = new object[] {
new XDeclaration("1.1", "UTF-8", "yes"),
new XProcessingInstruction("foo", "bar"),
new XElement("test")
};
xdoc = new XDocument(content);
出现以下错误:
System.ArgumentException: 非空格字符不能添加到内容中。
这两个示例难道不是完全相同的吗?发生了什么事情?