title: Is it bad practice to write inline event handlers
body: <p>Is it bad practice to write inline event handlers ?</p>
  
  <p>For me, I prefer use it when I want to use a local variable in the event handler like the following:</p>
  
  <p>I prefer this:</p>
  
  <pre><code>// This is just a sample
  private void Foo()
  {
      Timer timer = new Timer() { Interval = 1000 };
      int counter = 0; // counter has just this mission
      timer.Tick += (s, e) =&gt; myTextBox.Text = (counter++).ToString();
      timer.Start();
  }
  </code></pre>
  
  <p>Instead of this:</p>
  
  <pre><code>int counter = 0; // No need for this out of Boo &amp; the event handler
  
  private void Boo()
  {
      Timer timer = new Timer() { Interval = 1000 };
  
      timer.Tick += timer_Tick;
      timer.Start();
  }
  
  void timer_Tick(object sender, EventArgs e)
  {
      myTextBox.Text = (counter++).ToString();
  }
  </code></pre>