Debojyoti Das

Debojyoti Das

  • NA
  • 4
  • 2.5k

System.NullReferenceException Handled

May 1 2013 6:53 AM
Here's code I have written for a simple event based multiplier , this is the error I constantly get: Object reference not set to an instance of an object ath this line: txt3.Text = num3.ToString();.
I am a beginner, so what's my error here? What am I missing? Thanks. All the TextBoxes have value set in XAML.

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void txt2_TextChanged(object sender, TextChangedEventArgs e)
        {
            int num1, num2, num3;
            num1 = int.Parse(txt1.Text);
            num2 = int.Parse(txt2.Text);
            num3 = num1 * num2;
            txt3.Text = num3.ToString();
        }
    }


Answers (2)