title: Inside a switch statement, is there any way to refer to the value being switched?
body: <p>I have a block of code like </p>
  
  <pre><code>switch ( eqtn[curidx] )
  { 
      case Calculator.NOT:
          negateNextOp = true; 
          break;
          // CURMODE remains PARSEMODE.OPER
      case Calculator.OR:
      case Calculator.AND:
      case Calculator.XOR:
          lastop = eqtn[curidx++]; // Set last operator equal to the one at curidx; increment curidx
          CURMODE = PARSEMODE.NUM; // Expecting the next portion of the equation to be a number
          break;
      default: 
           throw new Exception(String.Format("At index {0}, encountered character {1} where expected to encounter beginning of operator",
                                         curidx,
                                         eqtn[curidx])
                               ); // Handle unexpected character 
  }
  </code></pre>
  
  <p>and, as you can see, twice inside the <code>switch</code> statement I refer to <code>eqtn[curidx]</code>, the number being <code>switch</code>ed. This seems like it could be made more elegant and optimal. I know that when a <code>switch</code> statement is compiled, the value inside the paranthesis something that is "cached" when the code runs and hits the <code>switch</code> statement. Since that value is the same as <code>eqtn[curidx]</code>, it could result in having two of the same value at different memory addresses (Right?) and that would be useless. </p>
  
  <p>Is there some equivalent of a <code>this</code> to refer to the value current being <code>switch</code>ed while inside the <code>switch</code> block?</p>