see my below code
protected void Page_Load(object sender, EventArgs e)
{
ExistsOnPath("efsui.exe"); ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
install(); ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
}
I have add more semicolon symbol in visual studio. Why visual studio allowed this? Is it wrong or correct?
See this image and red mark. build is succeeded
But error shows in this line ?
webClient.DownloadFile("http://www.who.int/inf-new/dnldtxt/introductions.zip", "";;;;;;;;;;;;;;;;);
Another fun, the below line is succeeded
private void install()
{
http://www.stackoverflow.com
return;
}
It succeeds because each statement that ends with a semi-colon doesn't have any syntax errors; they are empty. Now, as far as the generated code, nothing would get generated for those statements.
To better understand it you'd probably want to research how parsers work.
The
;
can be used as an empty statement in the C# language. Hence having many;
in a row is just fine because it's just a series of empty statements. Basically a no-opNote that this is not Visual Studio behavior but instead C# language behavior. The same code in other languages like VB.Net would produce a compilation error
Because semicolon
;
is a valid Empty Statement8.3 The empty statement
Also see: Statements (C# Programming Guide) - MSDN
EDIT:
well
;
semicolon is a valid empty statement but that doesn't mean that you can place that anywhere in your code.DownloadFile
method expects two parameters , would you place any statement in it like:Where
Console.Write
is a valid statement itself, but it can't be used for parameter.Because it is treating
http:
as a Labeled statements and anything after the colon is considered as part of label text. The above code will produce a warning