我有几个难以填充的课程:
public class ta_Room
{
public string url { get; set; }
public double price { get; set; }
public string room_code { get; set; }
}
public class ta_Hotel2
{
public int hotel_id { get; set; }
public Dictionary<string, ta_Room> room_types { get; set; }
}
在我的控制器中,我有:
[HttpGet]
public ta_Hotel2 hotel_inventory() //int api_version, string lang)
{
{
ta_Room room = new ta_Room();
room.price = 23;
room.room_code = "1";
room.url = "http://www.nme.com";
ta_Hotel2 hotel = new ta_Hotel2();
hotel.room_types.Add("Single", room);
但是,我在上面的最后一行得到了 NullReferenceException。
在下面的屏幕截图中,它显示酒店和房间对象都已创建 - 谁能告诉我我做错了什么?
谢谢,
标记