title: How to return a string from a method
body: <p>How can I return a value as text instead of <code>void</code>?</p>
  <p>Example:</p>
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      label1.Text = myvoid(&quot;foo&quot;, true);
      // Error: Cannot implicitly convert type void to string
  }
  
  public void myvoid(string key , bool data)
  {
      if (data == true)
      {
          string a = key + &quot; = true&quot;;
          MessageBox.Show(a); // How can I export this value to labe1.Text?
      }
      else
      {
          string a = key + &quot; = false&quot;;
          MessageBox.Show(a); // How can I export this value to labe1.Text?
      }
  }
  </code></pre>
  <p>How can I assign value <code>a</code> from a method that returns void, instead of showing a message box, and apply it to <code>label1.Text</code>?</p>