title: C# using index r in other functions
body: <p>I'm a C# beginner and like your input!</p>
  <p>I have a datagridview and want to do some stuff with the selected rows.
  I dont want to place all the tasks in one large function..... I'd like to split it up in seperate task-functions.
  I'm using 'r' to have the index of the selected line. But how do I get that index 'r' to be used in the functions do_stuff1, do_stuff2,....?</p>
  <p>Or am I going about this the wrong way?</p>
  <pre class="lang-cs prettyprint-override"><code>private void button1_Click_1(object sender, EventArgs e)
  {
      foreach (DataGridViewRow r in dataGridView1.SelectedRows)
      {
          do_stuff1();
          do_stuff2();
          do_stuff3();
      }
  }
  
  private void do_stuff1()
  {
      //do stuff1 with selected row r
  }
  
  ...
  </code></pre>
  <p>All help kindly appreciated!</p>