看我下面的代码
protected void Page_Load(object sender, EventArgs e)
{
ExistsOnPath("efsui.exe"); ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
install(); ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
}
Run Code Online (Sandbox Code Playgroud)
我在visual studio中添加了更多的分号符号.为什么visual studio允许这个?这是错的还是正确的?
看到这个图像和红色标记.构建成功

但错误显示在这一行?
webClient.DownloadFile("http://www.who.int/inf-new/dnldtxt/introductions.zip", "";;;;;;;;;;;;;;;;);
Run Code Online (Sandbox Code Playgroud)

另一个有趣的是,下面的线成功了
private void install()
{
http://www.stackoverflow.com
return;
}
Run Code Online (Sandbox Code Playgroud)
Hab*_*bib 10
因为分号;是有效的空语句
空语句什么都不做.
空语句:
;
如果在需要语句的上下文中没有要执行的操作,则使用空语句.
执行空语句只是将控制转移到语句的结束点.因此,如果可以访问空语句,则可以访问空语句的结束点.
另请参阅:语句(C#编程指南) - MSDN
空语句由单个分号组成.它什么都不做,可以在需要声明但不需要执行任何操作的地方使用.
编辑:
webClient.DownloadFile("http://www.who.int/inf-new/dnldtxt/introductions.zip", ;;;;;;;;;;;;;;;;"");
Run Code Online (Sandbox Code Playgroud)
但为什么错误显示在这一行?
well ; semicolon是一个有效的空语句,但这并不意味着你可以将它放在代码中的任何位置.DownloadFile方法需要两个参数,你会在其中放置任何语句,如:
webClient.DownloadFile("http://www.who.int/inf-new/dnldtxt/introductions.zip",
Console.Write("Some Text");, "");
Run Code Online (Sandbox Code Playgroud)
哪里Console.Write是有效的语句本身,但它不能用于参数.
为什么这段代码编译:
private void install()
{
http://www.stackoverflow.com
return;
}
Run Code Online (Sandbox Code Playgroud)
因为它被http: 视为标签语句,并且在冒号被视为标签文本的一部分之后的任何内容.上面的代码会产生警告
此标签尚未引用
| 归档时间: |
|
| 查看次数: |
649 次 |
| 最近记录: |