title: How to access variable of type 'var' outside of method?
body: <p>I'm trying to access the value stored in a method variable <code>var pitch</code> but I'm not sure how to access this method variable from another method.</p>
  
  <p>Usually I would declare the variable as a class field like this <code>private var pitch</code> but it seems you can't do this with a method var.</p>
  
  <p>Does any know how I could access the variable or variable's value from another method?</p>
  
  <p>This is the method where <code>pitch</code> is created and assigned the pitch value:</p>
  
  <pre><code>private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
          {
              const float PI = (float)System.Math.PI;
  
              var pitch = (int)((e.Pitch + PI) / (PI * 2.0f) * 10);
  
          }
  </code></pre>
  
  <p>And then the method where I want to access the value is as follows, but when I try to reference <code>pitch</code> it <code>doesn't exist in the current context</code>:</p>
  
  <pre><code>private void Pose_Triggered(object sender, PoseEventArgs e)
          {
              App.Current.Dispatcher.Invoke((Action)(() =&gt;
              {
  
                  poseStatusTbx.Text = "{0} arm Myo holding pose {1}" + e.Myo.Arm + e.Myo.Pose;
                  //error trying to reference pitch here.
                  pitch = pitchDefault;
  
  
              }));    
          }
  </code></pre>