Categories
Uncategorized

Why Does This C# Code Compile?

Here’s a cute little puzzler I got from the blog hackification — why the does code below compile?

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            https://www.globalnerdy.com
            System.Console.WriteLine("Hello from Global Nerdy!");
            System.Console.WriteLine("(Press ENTER to continue)");
            System.Console.ReadLine();
        }
    }
}

Here’s what the output of the program looks like:

Console output: "Hello from Global Nerdy! (Press ENTER to continue)"

Why does the program compile even though the first line of the Main() method is a “bareword” URL? See if you can figure it out on your own rather than running it through the compiler – doing that gives away the answer.

I’ll post the answer in the comments.