Was*_*RAR 3 c# exception-handling exception try-catch visual-studio
这可能是一个愚蠢的问题,但我想知道我的代码是否在编程上是正确的.
private void Connect()
{
try
{
// I will do something here
}
catch(Exception ex)
{
// If something bad happened
// I want to ignore the problem and continue the execution
// So, nothing will be placed in the catch block
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
那么,您的代码准确地描述了您的评论.然而,如果你没有连接就好像没有发生任何事情,这听起来是一个非常糟糕的主意.你在连接什么?什么机会是存在的,你会真的能够保持成功了?你甚至不想记录错误吗?你真的想要捕捉所有例外而不是特定的例外吗?
| 归档时间: |
|
| 查看次数: |
347 次 |
| 最近记录: |