我创建了这个程序和C#,几周前它运行正常.现在,我将所有这些代码复制到我正在处理的另一个项目中.我将它添加到我正在进行的项目中的全新C#类中.Visual Studio无法识别注释中"未找到"的程序集引用.
这是奇怪的,因为它们是在之前的程序中找到的.有谁知道为什么Visual Studio找不到这些程序集引用.
using System;
using System.Collections.Generic;
using System.Linq; //not found
using System.Text;
using XML_Creator; //not found
using System.Xml.Linq; //not found
using System.IO;
Run Code Online (Sandbox Code Playgroud) 我在这里创建一个简单的XML文件,当我这样做时,我得到关于非空白字符的错误,无法添加到内容中.
在构造函数中,我传递了一个字符串来创建第一个称为Root的节点.这会导致代码中出现非空白错误.有没有人看到这个问题.这是Visual Studio上的C#.
XDocument myDoc = new XDocument("Root");
myDoc.Add(
Enumerable.Range(0, 6).Select(i =>
new XElement("Entry",
new XAttribute("Address", "0123"),
new XAttribute("default", "0"),
new XElement("Descripion", "here is the description"),
new XElement("Data", "Data goes here ")
)));
myDoc.Save("foo.xml");
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个非常简单的XML文件的快速程序.我想创建一个XML文件,该文件使用'for循环'多次创建XML的一部分.当我构建时,我得到一个错误,说"无效的表达式术语"为'.我检查我的括号平衡,它似乎确实检查出来.
有谁知道这个错误意味着什么?
static void Main(string[] args)
{
XDocument myDoc = new XDocument(
new XDeclaration("1.0" ,"utf-8","yes"),
new XElement("Start"),
for(int i = 0; i <= 5; i++)
{
new XElement("Entry",
new XAttribute("Address", "0123"),
new XAttribute("default", "0"),
new XElement("Descripion", "here is the description"),
new XElement("Data", "Data goes here ")
);
}
);
}
Run Code Online (Sandbox Code Playgroud)