本文介绍了如何解析Nullable< DateTime>从SqlDataReader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DateTime.TryParse方法采用DateTime作为参数,而不是DateTime??
The DateTime.TryParse method takes a DateTime as an argument, not a DateTime? ?
现在我有以下代码:
if(!DateTime.TryParse(reader["Placed"].ToString(), out _placed)){ throw new Exception("Order's placed datetime could not be parsed."); }_placed的类型
where _placed is of type
Nullable<DateTime> _placed = null;如何解决?
推荐答案相反呢?
int x = reader.GetOrdinal("Placed"); if(!reader.IsDBNull(x)) _placed = reader.GetDateTime(x);更多推荐
如何解析Nullable< DateTime>从SqlDataReader
发布评论