title: Square root of a value using methods on C# window form
body: <p>I have been given an assignment on <strong>C# window form</strong> where I get to calculate an input textbox from a user, the user wants to input a value and then presses a radiobutton(square root) then clicks a normal button to get the result. Is it possible to get the result in a textbox (instead of a label)? If so, how do I do that using 'methods' (linking methods to the button_click one)? Also, why do I need to return a parameter value of a method? it doesn't let me execute without returning ;/</p>
  
  <pre><code>{
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
  
  
          private int square(int A)
          {
              if (rbSquare.Checked)
              {
                  Math.Sqrt(A);
                  return Convert.ToInt32(Math.Sqrt(A));
              }
              else
              {
                  return A;
              }
  
          }
          private void btncalculate_Click(object sender, EventArgs e)
          {
              int firstNum = Convert.ToInt32(tbinput.Text);
              int squareRoot = square(firstNum);
              tbResult.Text = "" + squareRoot;
  
          }
      }
  }
  </code></pre>