为什么编译器会出现这行代码的问题呢?

发布于 2024-07-21 05:26:26 字数 356 浏览 2 评论 0原文

整个解决方案在 Visual Studio 中构建得很好,但是当我运行 Nant 脚本来编译网站时,我在这一行收到几个错误:

string[] qs = (Request.QueryString["e"] ?? String.Empty)
               .Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries);

第一个错误是 Type Expected,然后是语法错误(预期值)、)预期、; 我之前在项目中使用过这样的行,它似乎并没有抱怨这些行。

我很确定错误是由于在该条件语句上调用 Split 引起的,但我不确定为什么。

The entire solution builds fine in Visual Studio, but when I run the Nant script to compile the website I get several errors on this line:

string[] qs = (Request.QueryString["e"] ?? String.Empty)
               .Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries);

First one says Type Expected, then Syntax error (value expected), ) expected, ; expected, etc. I've used lines like this before in the project and it doesn't seem to complain on those ones.

I'm pretty sure the error is coming from calling Split on that conditional statement, but I'm not sure why.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场信仰旅途 2024-07-28 05:26:26

我建议尝试

string[] qs = (Request.QueryString["e"] ?? String.Empty)
    .Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);

注意 new[] 转到 new char[]

I suggest trying

string[] qs = (Request.QueryString["e"] ?? String.Empty)
    .Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);

Note that new[] went to new char[].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文