【发布时间】:2011-04-14 14:59:40
【问题描述】:
让我们看看这个简单的 try/catch 示例...
try
{
// User inputs path of a file
if(!ValidPath)
throw new InvalidPathException();
}
catch InvalidPathException e
{
// Log error
// Re-throw the error.
throw;
}
几个问题。两者可能都是简单的答案。
- 在 catch 中的 throw 是否会返回并检查下一个 catch,然后是下一个,依此类推?
- 有没有办法回到原来的尝试?还是那是糟糕的编程习惯?
【问题讨论】:
-
您可以更清楚地了解“下一个”捕获块是什么。
标签: c# exception-handling try-catch