【发布时间】:2011-07-05 06:52:51
【问题描述】:
你!假设我有这么简单的 LINQ 表达式
IEnumerable<StopListMatchViewModel> res =
from rqResult in MatchesList
select new StopListMatchViewModel
(
)
{
MatchDate = DateTime.ParseExact(rqResult.Row["MatchDate"].ToString(), "dd.MM.yyyy HH:m:ss", fmtInfo),
Remark = rqResult.Row["Remark"].ToString()
}
如果无法根据指定的格式掩码解析字符串 - 我得到 FormatException。在调试器中,我可以在变量“res”的结果视图中了解它。实时我得到空集合。
在执行 LINQ 期间可能会发生许多不同异常的示例。我怎么能抓住和处理它们? try catch 块在这里不起作用,因为在我看来异常不会被引发。
【问题讨论】:
标签: c# linq exception-handling