-2

I have declared this list:

public ObservableCollection<Order> Orders { get; set; }

and then tried to create an object and add it to the list here:

Order curOrder = new Order(method, category, surchargeYesRadio.Checked, double.Parse(numTxt.Text));
Orders.Add(curOrder);

but for some strange reason, on the second line, it's throwing a null reference exception and breaking the program. I looked at my local variables and it shows it as having set values and everything. A screenshot is below:

Why a NullReferenceException?

Thanks in advance. I'm really confused.

Ethan Brouwer
  • 975
  • 9
  • 32

1 Answers1

1

Probably it is Orders that is null, not curOrder.

Georg
  • 5,626
  • 1
  • 23
  • 44