This compiles and runs:
xxxxxxxxxx
static void Main()
{
https://topanswers.xyz/csharp
}
Why isn’t this a compiler error?
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.