 <blockquote> <p>Declare some variable within a switch and use it externally.</p> </blockquote> <p>You <strong>can't</strong>. Variables defined inside the scope would only be visible within that scope. </p> <p>You have to declare your variable outside the <code>switch</code> statement and then you will be able to use it outside. </p> <p>I see that you are using <code>var</code> (Implicitly typed variable) and you can't declare it outside of your <code>switch</code> statement, <em>(since that needs to be assigned)</em>, You should see: <a href="http://stackoverflow.com/questions/8751507/declaring-an-implicitly-typed-variable-inside-conditional-scope-and-using-it-out">Declaring an implicitly typed variable inside conditional scope and using it outside</a> and the <a href="http://stackoverflow.com/a/8751779/961113">answer from Eric Lippert</a></p>