title: Convert string from TextBox to Number in WPF
body: <p>I have an application with four text boxes. I want user to be able to enter a value in the first three text boxes. The fourth will give the result <code>(box1 +  box2 + box3) / 3</code>.</p>
  
  <p>My textboxes look like this.</p>
  
  <pre><code>private void rBox_1_PreviewTextInput(object sender, TextCompositionEventArgs e)
      {
          CheckIsNumber(e);
      }
  </code></pre>
  
  <p>And a function to let user enter only digits.</p>
  
  <pre><code>private void CheckIsNumber (TextCompositionEventArgs e)
      {
          int result;
  
          if (!int.TryParse(e.Text, out result))
          {
              e.Handled = true;
          }
      }
  </code></pre>
  
  <p>The problem is I don't know how to convert and store a value from each textbox in an int.
  I've created a null int value to store. In <strong><em>public MainWindow()</em></strong>.</p>
  
  <pre><code>int box1_value;
  </code></pre>
  
  <p>And for function I did this.</p>
  
  <pre><code>public static int GetNumber (string arg)
      {
          int number = Int32.Parse(arg);
          return number;
      }
  </code></pre>
  
  <p>When I'm trying to apply this function this way, nothing happens. Program won't start, no errors, though.</p>
  
  <pre><code>public MainWindow()
      {
          InitializeComponent();
          int box1_value = GetNumber(rBox_1.Text);
      }
  </code></pre>