TalentTuner
TalentTuner

Reputation: 17556

Arbitrary and non sense string inside a code block

This is something , i don't understand , if i put any arbitrary string inside a code block, it will throw some compile time error but if i put something like below , it will not.

  static void Main(string[] args)
    {
        int i = 5;

       ghfhfghfghfghfhfghfhfghfghfghfhfghfghfghghttp://www.google.com
        Console.WriteLine(i.ToString());
        Console.ReadLine();
    }

any idea why this is happening? I just found it accidentally , not sure why , may be i am missing something.

Upvotes: 1

Views: 67

Answers (2)

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73482

That is a Label.

Look at the : at the end.

If you remove the : in the end. It won't compile

goto and label

Upvotes: 6

MarcinJuraszek
MarcinJuraszek

Reputation: 125630

ghfhfghfghfghfhfghfhfghfghfghfhfghfghfghghttp: is a label, because it's followed by :.

You can then use it with goto statement:

static void Main(string[] args)
{
    int i = 5;

    ghfhfghfghfghfhfghfhfghfghfghfhfghfghfghghttp://www.google.com
    Console.WriteLine(i.ToString());
    Console.ReadLine();

    goto ghfhfghfghfghfhfghfhfghfghfghfhfghfghfghghttp;
}

Upvotes: 4

Related Questions