Esempio:
codice:
 void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                Metodo(textBox1,textBox2,textBox3);
            }
        }

        private void Metodo(TextBox numero_a,TextBox numero_b,TextBox numero_c)
        {
            double A;
            double B;
            double C;
            double D;
            try
            {
                A = double.Parse(numero_a.Text);
                B = double.Parse(numero_b.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("I dati di input sono sbagliati!", "ERRORE!", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
            C = A + B + D;
            numero_c.Text = C.ToString();
        }