title: Is it possible to declare a global variable for an event handler?
body: <p>How and where can the variable <strong>i</strong> below be declared as a global variable?(I get errors when I declare it above the main below MyClass)</p>
  <pre><code>    class MyClass
      {
       
          public static void Main()
          {
              
      
              mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
              
      
          }
       
          public static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
          {
            int i;
      
           //
           my_method();
          }
      
      private static void my_method(){
      
      //
      
          }
  
  }
  </code></pre>
  <p>In my code I want <strong>i</strong> to be stored as global variable for some reason to store the previous value of <strong>i</strong>.</p>