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 (box1 +  box2 + box3) / 3.
My textboxes look like this.
private void rBox_1_PreviewTextInput(object sender, TextCompositionEventArgs e)
    {
        CheckIsNumber(e);
    }
And a function to let user enter only digits.
private void CheckIsNumber (TextCompositionEventArgs e)
    {
        int result;
        if (!int.TryParse(e.Text, out result))
        {
            e.Handled = true;
        }
    }
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 public MainWindow().
int box1_value;
And for function I did this.
public static int GetNumber (string arg)
    {
        int number = Int32.Parse(arg);
        return number;
    }
When I'm trying to apply this function this way, nothing happens. Program won't start, no errors, though.
public MainWindow()
    {
        InitializeComponent();
        int box1_value = GetNumber(rBox_1.Text);
    }
 
     
     
     
    