title: Using lambda for the first time. Looking to put more code inline if possible
body: <p>I'm currently trying to teach my self how to use lambda expressions (really like how they look)</p>
  
  <p>On my win form I have 2 buttons which are used to browse directories, the user selected directory is then placed in a corresponding text box. This is what I have so far.</p>
  
  <p>In the setDirectory event is there any way I can do the button check inline? I'm really looking to clean up the code in the setDirectory event.</p>
  
  <pre><code>        private void setDirectory_Click(object sender, EventArgs e)
          {
             Button dirButton = sender as Button;
             TextBox dirTextBox;
  
             if (dirButton.Name == fromDirButton.Name)
                 dirTextBox = fromTextBox;
             else
                 dirTextBox = toTextBox;
  
             Func&lt;string&gt; setDirectory = SetDirectory();
             fromTextBox.Invoke((MethodInvoker)(() =&gt; { dirTextBox.Text = setDirectory(); }));
          }
  
          private static Func&lt;string&gt; SetDirectory()
          {
             using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
             {
                 folderBrowserDialog.Description = "Select Path";
                 folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer;
                 folderBrowserDialog.ShowDialog();
                 return () =&gt; folderBrowserDialog.SelectedPath != "" ? folderBrowserDialog.SelectedPath : "";
             }
          }
  </code></pre>