c# - C#中抛出异常后如何继续执行代码?
问题描述
抛出异常后如何更改此代码以继续执行应用程序?
if (str is null || str == string.Empty)
{
throw new Exception("Wrong str");
}
解决方案
try
{
if (str is null || str == string.Empty)
{
throw new Exception("Wrong str");
}
}
catch (Exception strException)
{
Console.WriteLine(strException.Message);
}
//Continue......
推荐阅读
- c++ - 如何将 cpr 的 get 响应转换为 json 对象?
- javascript - 如何在没有 google plus 个人资料图片的情况下嵌入 Google Maps?
- php - 如何解决包含希伯来语文本的 Excel 工作表中的缓慢移动和滚动问题?
- html - 如何消除内容下的空间?
- pandas - 设置多个应用列
- javascript - 映射和传递 onClick 函数作为道具后如何定位特定元素
- swift - 如何编辑隐藏在 Xcode Storyboard 中其他视图后面的视图?
- ssl - 有什么方法可以在免费的 heroku dyno 上添加免费的 SSL 证书?
- web-scraping - 使用 Google Search API 访问 Google Enchanced Events 结果的方法?
- r - 在R中循环一个数据帧以有条件地生成另一个数据帧,第一个数据帧中的每一行都有一个或多个行