syntax add tag
5 years ago Hosch250

This compiles and runs:

Why isn’t this a compiler error?

Top Answer
5 years ago Hosch250

This compiles because the http: part parses as a line label, and the //... part parses as a comment.

You can check the parse tree and confirm this at RoslynGenerator.

The comment is part of the trailing trivia list on the colon token. If we had a statement, such as Console.WriteLine("Something..."); after the : token, that would be included in the statement node in the tree.

5 years
Hosch250 — Thursday, 30th Apr 2020 02:49

Good suggestion 😃

3 days
joulev — Monday, 27th Apr 2020 13:21

I suppose http://stackoverflow.com/ should be replaced with https://topanswers.xyz/csharp? 😃

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.