具有以下代码
的行 // Load screen containers
serverTest = document.SelectSingleNode("Server/". this.serverName . "/test").InnerText;
c#不喜欢"。串联字符,不确定在这里做什么。
Servertest是我的类的属性,btw
oops使用php串联字符,一个小时前使用该语言。
可以删除此mod之一,很抱歉占用空间。
您必须做这样的事情。
document.SelectSingleNode(@"Server/" + this.serverName + @"/test").InnerText;
用于字符串串联,使用" " plus operator或string.format。如果它包含很多变量
document.SelectSingleNode(@"Server/" + this.serverName + @"/app").InnerText;
对于大量变量(一旦您需要基于属性的节点检索,可以使用多个参数(: -
// for [Server/localhost/App/MyApp/Module/Admin/Action/Test"
var location = string.Format(@"Server/{0}/App/{1}/Module/{2}/Action/{3}", this.serverName, this.appName, this.moduleName, this.actionName);
document.SelectSingleNode(location).InnerText;
通过将位置与检索函数分开,您可以轻松调试并在任何值不正确的情况下进行登录。还使代码可读的恕我直言。但是,对于单个值,在大多数情况下,使用串联在线可以是可以的。