c# - 我不明白代码的 Try Catch Exception 部分
问题描述
在一个项目中,我发现了这部分代码:
public String EndDateText
{
get
{
try
{
if (_endDate != null)
return _endDate.Value.ToString("o");
else
return "";
}
catch (Exception)
{
_endDate = new DateTimeOffset();
throw;
}
}
set
{
if (value != null)
_endDate = DateTimeOffset.Parse(value);
}
}
我不明白这行_endDate = new DateTimeOffset(); 在捕获部分。
为什么要创建 _endDate 的新实例?
感谢您的帮助。
解决方案
推荐阅读
- javascript - 使用 TypeORM 在 PostgreSQL 的一列中保存数据流
- html - 为每个页面添加页眉和页脚
- spring - 如何使用带有 hasRole 的 SpEL 来设置 html 属性?
- sql - SELECT with LEFT JOIN 执行两次数学运算?
- vue.js - vue实例数据和网络响应不一样,bug在哪里?
- javascript - 为 React 组件提供替代渲染方法
- android - 随叫随到的问题
- opencv3.0 - 在 OpenCV 拼接管道中查看匹配的特征
- scala - 带有 distinctOn 的光滑通用查询
- swift - Vapor 3 - URLSession 还是 AJAX?