title: Variable declaration in a C# switch statement
body: <p>Why is it that in a C# switch statement, for a variable used in multiple cases, you only declare it in the first case?</p>
  
  <p>For example, the following throws the error "A local variable named 'variable' is already defined in this scope".</p>
  
  <pre><code>switch (Type)
  {
      case Type.A:
              string variable = "x";
                  break;
      case Type.B:
              string variable = "y";
                  break;
  }
  </code></pre>
  
  <p>However, per the logic, the initial declaration should not be hit if the type is <code>Type.B</code>. Do all variables within a switch statement exist in a single scope, and are they created/allocated before any logic is processed?</p>