例子:(报错了)

  public DateTime? time { get; set; }

  time = item.HospOutDate.HasValue ? DateTime.Parse(item.HospOutDate.Value.ToString("yyyy-MM-dd HH:mm:ss")) : null;

错误提示:无法确定条件表达式的类型,因为“<null>”和“System.DateTime”之间没有隐式转换

 

解决办法:

添加: DateTime? TimeNull = null;

time = item.HospOutDate.HasValue ? DateTime.Parse(item.HospOutDate.Value.ToString("yyyy-MM-dd HH:mm:ss")) : TimeNull ;

相关文章:

  • 2021-07-01
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
相关资源
相似解决方案