title: Pass values from one method to use them in another method in C#
body: <p>How can I use values from the <code>timer_lights_status_Tick</code> method in <code>groupBox1_Paint</code>?</p>
  
  <pre><code>public Main()
  {
      InitializeComponent();
  }
  
  private void groupBox1_Paint(object sender, PaintEventArgs e)
  {
      // Here is where I want to use those variables: red_light1, yellow_light1…
  }
  
  public void timer_lights_status_Tick(object sender, EventArgs e)
  {
      int red_light1, yellow_light1, green_light1,
          red_light2, yellow_light2, green_light2;
  
      red_light1    = Convert.ToInt32(comport.message(4, 8, 32));
      yellow_light1 = Convert.ToInt32(comport.message(4, 8, 33));
      green_light1  = Convert.ToInt32(comport.message(4, 8, 34));
  
      red_light2    = Convert.ToInt32(comport.message(4, 8, 35));
      yellow_light2 = Convert.ToInt32(comport.message(4, 8, 36));
      green_light2  = Convert.ToInt32(comport.message(4, 8, 37));
  }
  </code></pre>