It’s absolutely fine – although there are two caveats:
- If you’re modifying a local variable from within a closure, you should make sure you understand what you’re doing.
- You won’t be able to unsubscribe from the event
Typically I only inline really simple event handlers – for anything more involved, I use lambda expressions (or anonymous methods) to subscribe with a call to an method with a more appropriate method:
// We don't care about the arguments here; SaveDocument shouldn't need parameters
saveButton.Click += delegate { SaveDocument(); };