title: Is it OK to overload ShowDialog() so that a child form returns information as an out parameter?
body: <p>In an earlier question about <a href="https://stackoverflow.com/questions/280579/c-beginner-help-how-do-i-pass-a-value-from-a-child-back-to-the-parent-form">how to return a string from a dialog window</a>, <strong>yapiskan</strong> suggested <a href="https://stackoverflow.com/questions/280579/c-beginner-help-how-do-i-pass-a-value-from-a-child-back-to-the-parent-form#280731">overloading the child form's ShowDialog() method</a> to include an out parameter.</p>
  
  <p>My question is whether or not this is a good approach in C#.</p>
  
  <p>Here is some example code, based on yapiskan's suggestion.  In the child form (in this example, it's a form with a textbox on it), you just need to add the ShowDialog overload and assign UI values to the out parameter:</p>
  
  <pre><code>public DialogResult ShowDialog(out string s)
  {
      DialogResult result = this.ShowDialog();
      s = this.textBox1.Text;
      return result;
  }
  </code></pre>
  
  <p>And to show the form and retrieve the entered text, you do this:</p>
  
  <pre><code>using (CustomDialog frm = new CustomDialog())
  {
      string s;
      if (frm.ShowDialog(out s) == DialogResult.OK)
      {
          // do something with s
      }
  }
  </code></pre>
  
  <p>One advantage I can think of is that this approach forces the user of the CustomDialog form to get the information it contains through the form's ShowDialog method (rather than from a who-knows-what-it's-called method like GetMyData() or something).</p>