in switch case if we write "default" as any word or single letter it does not throw an error

c#, switch-statement

Solution

It is compiling because `hello:` is a label and thus can be the destination of a `goto`. When I compiled this I got warnings about an unreferenced label (since I did not have a goto)

Here is an example you could throw in LINQPad - you will notice that it prints both "1" and "hello":

switch(1)
{
    case 1:
        "1".Dump();
        goto hello;
    break;

    hello:
        "hello".Dump();
        break;
}

Problem

In a `switch`, if we write any word or single letter instead of `default` it does not throw an error. e.g. ``` switch(10) { case 1: break; hello: break; } ``` It runs without throwing an error. Can anyone explain how this works?

Original source