我有一个名为 HoursOfOperation 的模型(ASP.NET MVC 4,C#):
public class HoursOfOperation
{
public List<DayTimes> Monday { get; set; }
public List<DayTimes> Tuesday { get; set; }
public List<DayTimes> Wednesday { get; set; }
public List<DayTimes> Thursday { get; set; }
public List<DayTimes> Friday { get; set; }
public List<DayTimes> Saturday { get; set; }
public List<DayTimes> Sunday { get; set; }
}
和一个白天
public class DayTimes
{
public int Status { get; set; }
public string From { get; set; }
public string To { get; set; }
}
现在我正在尝试向 Monday 实体添加一个新集合,如下所示:
var _vm = new HoursOfOperation();
_vm.Monday.Add(new DayTimes{
From = day.From.ToString(),
To = day.To.ToString(),
Status = (int)day.Status
});
一旦上述语句被执行,我就会得到一个"Object reference not set to an instance of an object."
例外
现在我已经检查并day.From.ToString()
有一个"08:00:00"
,day.To.ToString() 有"09:30:00"
和 day.Status1
在该语句引发异常的时间有一个。
有任何想法吗?