所以我有这段代码可以使用 c# 发布JSON data到我的REST API
try
{
tempquantityofmenu = entQuantity.Text;
CustList custo = new CustList();
CustomerOrder custo1 = new CustomerOrder()
{
menu_name = tempnameofmenu,
menu_quantity = tempquantityofmenu,
menu_code = tempcodeofmenu
};
custo.CUSTOMER_ORDER.Add(custo1);
await Navigation.PushAsync(new OrdernowCategory());
}
catch(Exception ex)
{
DisplayAlert("error", ex.ToString(), "OK");
}
然后我得到这个 System.NullReferenceExeption: Object Reference not set to an instance of an object
public class CustomerOrder
{
public string menu_name { get; set; }
public string menu_quantity { get; set; }
public string menu_code { get; set; }
}
public class CustList
{
public List<CustomerOrder> CUSTOMER_ORDER { get; set; }
}
我认为我的问题是当向CUSTOMER_ORDER内部添加项目时try catch不起作用
德玛西亚99
喵喔喔
相关分类