C# switch variable initialization: Why does this code NOT cause a compiler error or a runtime error?
Asked 2009-05-14T15:51:02.903
10
...
case 1:
string x = "SomeString";
...
break;
case 2:
x = "SomeOtherString";
...
break;
...
Is there something that I am not understanding about the switch statement in C#? Why would this not be an error when case 2 is used?
Edit: This code works and doesn't throw an error.